Skip to content

Commit eac8429

Browse files
committed
add an external scanner for arrow shorthand, basically just looksahead to avoid '{', this seems to solve ()=>{}() being treated as legal
1 parent b9290a4 commit eac8429

File tree

4 files changed

+37658
-36943
lines changed

4 files changed

+37658
-36943
lines changed

grammar.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = grammar({
1515
$._automatic_semicolon,
1616
$._template_chars,
1717
$._ternary_qmark,
18+
$._shorthand_arrow,
1819
$.html_comment,
1920
'||',
2021
// We use escape sequence and regex pattern to tell the scanner if we're currently inside a string or template string, in which case
@@ -769,11 +770,10 @@ module.exports = grammar({
769770
)),
770771
$._call_signature,
771772
),
772-
'=>',
773-
field('body', choice(
774-
$.expression,
775-
$.statement_block,
776-
)),
773+
choice(
774+
seq($._shorthand_arrow, field('body', $.expression)),
775+
seq(choice('=>', $._shorthand_arrow), field('body', $.statement_block,)),
776+
),
777777
),
778778

779779
// Override

src/grammar.json

Lines changed: 50 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)