diff --git a/cogs/r5rs.scm b/cogs/r5rs.scm index 3d19fefd7..8e3c1093f 100644 --- a/cogs/r5rs.scm +++ b/cogs/r5rs.scm @@ -45,6 +45,8 @@ (check-equal? "Parsing octal" #o0777 511) (check-equal? "Parsing binary" #b0110 6) +(check-equal? "Empty anonymous function with variable arity" ((lambda x x)) '()) + (check-equal? "filter treats lists as true" (filter (lambda (n) (list 1 2)) (list 1 2)) '(1 2)) (check-equal? diff --git a/crates/steel-core/src/steel_vm/const_evaluation.rs b/crates/steel-core/src/steel_vm/const_evaluation.rs index 3c09f73de..c2b306c0e 100644 --- a/crates/steel-core/src/steel_vm/const_evaluation.rs +++ b/crates/steel-core/src/steel_vm/const_evaluation.rs @@ -619,14 +619,16 @@ impl<'a> ConsumingVisitor for ConstantEvaluator<'a> { return self.eval_kernel_function(ident.clone(), func, Vec::new(), &[]); } else { if let ExprKind::LambdaFunction(f) = &func { - if !f.args.is_empty() { - stop!(ArityMismatch => format!("function expected {} arguments, found 0", f.args.len())) - } + if !f.rest { + if !f.args.is_empty() { + stop!(ArityMismatch => format!("function expected {} arguments, found 0", f.args.len())) + } - // If the body is constant we can safely remove the application - // Otherwise we can't eliminate the additional scope depth - if self.to_constant(&f.body).is_some() { - return Ok(f.body.clone()); + // If the body is constant we can safely remove the application + // Otherwise we can't eliminate the additional scope depth + if self.to_constant(&f.body).is_some() { + return Ok(f.body.clone()); + } } }