Skip to content

Commit

Permalink
rest argument shouldn't report arity mismatches in language server
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwparas committed Dec 25, 2023
1 parent 5721aea commit a3e9c46
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions crates/steel-language-server/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ impl DiagnosticGenerator for StaticArityChecker {
.trim_end_matches(interned.resolve())
.trim_end_matches("__%#__");

log::debug!("Searching for: {} in {}", name, module_path_to_check);

let module = context
.engine
.modules()
Expand All @@ -195,7 +193,17 @@ impl DiagnosticGenerator for StaticArityChecker {
// Don't include rest args for now
if let Some(d) = top_level_define {
if let ExprKind::LambdaFunction(l) = &d.body {
if !l.rest {
let mut rest = false;

for arg in &l.args {
if let Some(ident) = arg.atom_identifier() {
if ident.resolve() == "." {
rest = true;
}
}
}

if !rest && !l.rest {
arity_checker.known_functions.insert(id, l.args.len());
}
}
Expand Down

0 comments on commit a3e9c46

Please sign in to comment.