diff --git a/CHANGES.md b/CHANGES.md index 350b7c9573..1fc6c3dc86 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,8 @@ * Compiler: fix location for parsing errors when last token is a virtual semicolon * Compiler: fix variable renaming with nested const/let decl with identical names * Compiler: fix variable renaming inside js method +* Compiler: consise body should allow any expression but object literals +* Compiler: preverve [new] without arguments [new C] (vs [new C()] # 5.2.0 (2023-04-28) - Lille ## Features/Changes diff --git a/compiler/tests-compiler/js_parser_printer.ml b/compiler/tests-compiler/js_parser_printer.ml index fab1c45f8c..53014de09a 100644 --- a/compiler/tests-compiler/js_parser_printer.ml +++ b/compiler/tests-compiler/js_parser_printer.ml @@ -609,7 +609,7 @@ if(a) { this(is, not, small) + this(is, bigger); } |}] -let%expect_test "" = +let%expect_test "consise body can be anything that doesn't start with curly brackets" = print ~debuginfo:false ~compact:false @@ -618,10 +618,29 @@ let%expect_test "" = var e = function () { } () var e = f(x => function () { } ()) + +var e = f(x => new class f {}) +|}; + [%expect + {| + var e = function(){}(); + var e = f(x=>function(){}()); + var e = f(x=>new class f{}); |}] + +let%expect_test "new kw with no arguments should be preserve" = + print + ~debuginfo:false + ~compact:false + ~report:true + {| +var e = new f +var e = new f() +var e = new class f {} +var e = new (class f {}) |}; [%expect {| - cannot parse js (from l:4, c:31)@. |}] + var e = new f; var e = new f(); var e = new class f{}; var e = new class f{}; |}] let%expect_test "error reporting" = (try