Skip to content

Commit 8975afe

Browse files
committed
Allow 'union' and 'default' as bindings in patterns
1 parent 63eba73 commit 8975afe

File tree

4 files changed

+59908
-60203
lines changed

4 files changed

+59908
-60203
lines changed

corpus/declarations.txt

+17
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,23 @@ let a = if b {
519519
(block
520520
(identifier))))))
521521

522+
================================================================================
523+
Let declarations with contextual keywords as names
524+
================================================================================
525+
526+
let default = 1;
527+
let union = 2;
528+
529+
--------------------------------------------------------------------------------
530+
531+
(source_file
532+
(let_declaration
533+
(identifier)
534+
(integer_literal))
535+
(let_declaration
536+
(identifier)
537+
(integer_literal)))
538+
522539
================================================================================
523540
Structs
524541
================================================================================

grammar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,6 @@ module.exports = grammar({
710710
field('pattern', choice(
711711
$._pattern,
712712
$.self,
713-
$._reserved_identifier,
714713
)),
715714
':',
716715
field('type', $._type)
@@ -1351,6 +1350,7 @@ module.exports = grammar({
13511350
$.tuple_pattern,
13521351
$.tuple_struct_pattern,
13531352
$.struct_pattern,
1353+
$._reserved_identifier,
13541354
$.ref_pattern,
13551355
$.slice_pattern,
13561356
$.captured_pattern,

src/grammar.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -4138,10 +4138,6 @@
41384138
{
41394139
"type": "SYMBOL",
41404140
"name": "self"
4141-
},
4142-
{
4143-
"type": "SYMBOL",
4144-
"name": "_reserved_identifier"
41454141
}
41464142
]
41474143
}
@@ -7959,6 +7955,10 @@
79597955
"type": "SYMBOL",
79607956
"name": "struct_pattern"
79617957
},
7958+
{
7959+
"type": "SYMBOL",
7960+
"name": "_reserved_identifier"
7961+
},
79627962
{
79637963
"type": "SYMBOL",
79647964
"name": "ref_pattern"

0 commit comments

Comments
 (0)