From 0105eb7382801b56781308ea94b3aeffa6fd867f Mon Sep 17 00:00:00 2001 From: Marmare314 <49279081+Marmare314@users.noreply.github.com> Date: Thu, 13 Apr 2023 16:07:58 +0200 Subject: Fix function sinks (#638) --- src/syntax/parser.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/syntax/parser.rs') diff --git a/src/syntax/parser.rs b/src/syntax/parser.rs index 42183f3a..7c05eebc 100644 --- a/src/syntax/parser.rs +++ b/src/syntax/parser.rs @@ -1069,6 +1069,7 @@ fn validate_dict(p: &mut Parser, m: Marker) { } fn validate_params(p: &mut Parser, m: Marker) { + let mut used_spread = false; let mut used = HashSet::new(); for child in p.post_process(m) { match child.kind() { @@ -1086,12 +1087,24 @@ fn validate_params(p: &mut Parser, m: Marker) { } SyntaxKind::Spread => { let Some(within) = child.children_mut().last_mut() else { continue }; - if within.kind() != SyntaxKind::Ident { + if used_spread { + child.convert_to_error("only one argument sink is allowed"); + continue; + } + used_spread = true; + if within.kind() == SyntaxKind::Dots { + continue; + } else if within.kind() != SyntaxKind::Ident { within.convert_to_error(eco_format!( "expected identifier, found {}", within.kind().name(), )); child.make_erroneous(); + continue; + } + if !used.insert(within.text().clone()) { + within.convert_to_error("duplicate parameter"); + child.make_erroneous(); } } SyntaxKind::LeftParen | SyntaxKind::RightParen | SyntaxKind::Comma => {} -- cgit v1.2.3