Skip to content

Commit

Permalink
Allow assignment to be split over multiple lines
Browse files Browse the repository at this point in the history
Since this case used a literal "=" in the grammar, rather than an
`_equal_sign`, it did not indicate to the scanner that the `=` was an
allowed character. This prevented the scanner from suppressing
semicolons.
  • Loading branch information
alex-pinkus committed Mar 3, 2024
1 parent be1bb78 commit 9723354
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,8 @@ module.exports = grammar({
),
_try_operator_type: ($) =>
choice(token.immediate("!"), token.immediate("?")),
_assignment_and_operator: ($) => choice("+=", "-=", "*=", "/=", "%=", "="),
_assignment_and_operator: ($) =>
choice("+=", "-=", "*=", "/=", "%=", $._equal_sign),
_equality_operator: ($) => choice("!=", "!==", $._eq_eq, "==="),
_comparison_operator: ($) => choice("<", ">", "<=", ">="),
_three_dot_operator: ($) => alias("...", "..."), // Weird alias to satisfy highlight queries
Expand Down
1 change: 0 additions & 1 deletion script-data/known_failures.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
ReactKit/ReactKitTests/OperationTests.swift
GRDB/GRDB/Core/Statement.swift
lottie-ios/Sources/Public/Animation/LottieAnimationLayer.swift
14 changes: 14 additions & 0 deletions test/corpus/expressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1550,3 +1550,17 @@ let result = try !(inner1() || inner2())
(simple_identifier)
(call_suffix
(value_arguments)))))))))))

================================================================================
Assignment split over multiple lines
================================================================================
savedValue
= 0

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

(source_file
(assignment
(directly_assignable_expression
(simple_identifier))
(integer_literal)))

0 comments on commit 9723354

Please sign in to comment.