diff --git a/lang/semgrep-grammars/src/semgrep-elixir/grammar.js b/lang/semgrep-grammars/src/semgrep-elixir/grammar.js index 5d9d27b6..3c1a9cc4 100644 --- a/lang/semgrep-grammars/src/semgrep-elixir/grammar.js +++ b/lang/semgrep-grammars/src/semgrep-elixir/grammar.js @@ -49,16 +49,22 @@ module.exports = grammar(base_grammar, { // keyword/pairs, such as // foo(some_arg: 0, ...) // %{some_item: 0, ...} - // Also note that now there is ambiguity whether foo(...) is an - // identity or pair, we set the pair rule to have a lower - // precedence pair: ($, previous) => { - return prec(-1, choice( + return choice( previous, $.semgrep_ellipsis, - )); + ); }, + // Note that because of the pair rule above, now there is + // ambiguity whether the ellipsis in foo(...) is an + // ellipsis for positional or keyword arguments. If ... matches + // with the identity rule, it will be considered a positional + // argument. If ... matches with semgrep_ellipsis, it will be + // part of parsing the pair rule, which means its a keyword + // argument. In practice, this doesn't matter because either + // way, they will become ParamEllipsis in the Generic AST + // anyway. semgrep_ellipsis: $ => prec(-1, '...'), _expression: ($, previous) => choice(