Skip to content

Commit 5ba7936

Browse files
committed
Compiler: fix 'as' keyword as ident
1 parent b21d60b commit 5ba7936

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

CHANGES.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 5.5.2 (2023-12-01) - Lille
1+
# dev (2023-??-??) - Lille
22

33
## Features/Changes
44
* Compiler: try to preserve clorures ordering between ml and js
@@ -7,6 +7,7 @@
77
* Compiler: js-parser now accept all the line terminators defined in the spec
88
* Compiler: js-parser: fix support for LHS assignment target
99
* Compiler: js-parser: fix parser of default export
10+
* Compiler: js-parser: allow 'as' as ident
1011

1112
# 5.5.2 (2023-12-01) - Lille
1213

compiler/lib/js_parser.mly

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ ident:
11841184
(* add here keywords which are not considered reserved by ECMA *)
11851185
ident_semi_keyword:
11861186
(* TODO: would like to add T_IMPORT here, but cause conflicts *)
1187-
(* can have AS and ASYNC here but need to restrict arrow_function then *)
1187+
| T_AS { T_AS }
11881188
| T_ASYNC { T_ASYNC }
11891189
| T_FROM { T_FROM }
11901190
| T_GET { T_GET }

compiler/tests-compiler/js_parser_printer.ml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,17 @@ let%expect_test "assignment targets" =
676676
[[[x = 5]], {a, b}, ...rest] = [];
677677
({a: [a, b] = f(), b = 3, ...rest} = {}); |}]
678678

679+
let%expect_test "as keyword" =
680+
print
681+
~debuginfo:false
682+
~compact:false
683+
~report:true
684+
{|
685+
const as = () => () => ts(void 0, void 0, void 0, function* () {})
686+
|};
687+
[%expect {|
688+
const as = ()=>()=>ts(void 0, void 0, void 0, function*(){}); |}]
689+
679690
let%expect_test "error reporting" =
680691
(try
681692
print ~invalid:true ~compact:false {|

0 commit comments

Comments
 (0)