Skip to content

Commit b77ee0f

Browse files
Add await as reserved identifier
1 parent 6ec8014 commit b77ee0f

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

Diff for: grammar.js

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ module.exports = grammar({
6464
[$.primary_expression, $.statement_block, 'object'],
6565
[$.import_statement, $.import],
6666
[$.export_statement, $.primary_expression],
67+
[$.primary_expression, $.await_expression],
6768
],
6869

6970
conflicts: $ => [
@@ -1143,6 +1144,7 @@ module.exports = grammar({
11431144
'get',
11441145
'set',
11451146
'async',
1147+
'await',
11461148
'static',
11471149
'export'
11481150
),

Diff for: test/corpus/expressions.txt

+30
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ Objects with reserved words for keys
319319
set: function () {},
320320
static: true,
321321
async: true,
322+
await: true,
322323
};
323324

324325
---
@@ -340,6 +341,7 @@ Objects with reserved words for keys
340341
(property_identifier)
341342
(function (formal_parameters) (statement_block)))
342343
(pair (property_identifier) (true))
344+
(pair (property_identifier) (true))
343345
(pair (property_identifier) (true)))))
344346

345347
============================================
@@ -422,6 +424,7 @@ Classes with reserved words as methods
422424
class Foo {
423425
catch() {}
424426
finally() {}
427+
await() {}
425428
}
426429

427430
---
@@ -434,6 +437,10 @@ class Foo {
434437
(property_identifier)
435438
(formal_parameters)
436439
(statement_block))
440+
(method_definition
441+
(property_identifier)
442+
(formal_parameters)
443+
(statement_block))
437444
(method_definition
438445
(property_identifier)
439446
(formal_parameters)
@@ -1358,6 +1365,29 @@ yield db.users.where('[endpoint+email]')
13581365
(property_identifier))
13591366
(arguments (string (string_fragment)))))))
13601367

1368+
============================================
1369+
Reserved words as identifiers
1370+
============================================
1371+
1372+
function await(await) { await: await (await + await (0)); }
1373+
1374+
---
1375+
1376+
(program
1377+
(function_declaration
1378+
(identifier)
1379+
(formal_parameters (identifier))
1380+
(statement_block
1381+
(labeled_statement
1382+
(statement_identifier)
1383+
(expression_statement
1384+
(call_expression
1385+
(identifier)
1386+
(arguments
1387+
(binary_expression
1388+
(identifier)
1389+
(call_expression (identifier) (arguments (number)))))))))))
1390+
13611391
============================================
13621392
JSX
13631393
============================================

0 commit comments

Comments
 (0)