Skip to content

Commit

Permalink
Fix precedence of prefix expressions vs nav expressions
Browse files Browse the repository at this point in the history
Fixes #272
  • Loading branch information
alex-pinkus committed Feb 19, 2023
1 parent f7d6420 commit 4a59d68
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const PRECS = {
infix_operations: 9,
nil_coalescing: 8,
check: 7,
prefix_operations: 7,
comparison: 6,
postfix_operations: 6,
equality: 5,
Expand All @@ -55,6 +54,7 @@ const PRECS = {
range_suffix: -2,
ternary_binary_suffix: -2,
await: -2,
prefix_operations: -2,
assignment: -3,
comment: -3,
lambda: -3,
Expand Down Expand Up @@ -512,7 +512,7 @@ module.exports = grammar({
)
),
navigation_expression: ($) =>
prec.left(
prec.right(
PRECS.navigation,
seq(
field("target", choice($._navigable_type_expression, $._expression)),
Expand Down
21 changes: 21 additions & 0 deletions test/corpus/expressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1217,3 +1217,24 @@ foo()
(call_suffix
(value_arguments)))
(fully_open_range))

================================================================================
Negated prefix expressions
================================================================================
let test = !Enum.case.variable

--------------------------------------------------------------------------------

(source_file
(property_declaration
(pattern
(simple_identifier))
(prefix_expression
(bang)
(navigation_expression
(navigation_expression
(simple_identifier)
(navigation_suffix
(simple_identifier)))
(navigation_suffix
(simple_identifier))))))

0 comments on commit 4a59d68

Please sign in to comment.