diff options
author | 2021-08-11 16:22:48 -0700 | |
---|---|---|
committer | 2021-08-11 16:22:48 -0700 | |
commit | 70912ec46f4633e474625539c49c19dcfb3d9823 (patch) | |
tree | 99db6a078ed2e3ed0b58a29fb6ce46dc5091eba0 /src/js_parser/js_parser.zig | |
parent | 3c6d687423b237d0c5b4d9a01e809a3b0bf6bac6 (diff) | |
download | bun-70912ec46f4633e474625539c49c19dcfb3d9823.tar.gz bun-70912ec46f4633e474625539c49c19dcfb3d9823.tar.zst bun-70912ec46f4633e474625539c49c19dcfb3d9823.zip |
Fix incorrect error generated for shorthand properties with initializers
Former-commit-id: 3637987b9ba42805c60ed664769e8fc46fa524f1
Diffstat (limited to 'src/js_parser/js_parser.zig')
-rw-r--r-- | src/js_parser/js_parser.zig | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/js_parser/js_parser.zig b/src/js_parser/js_parser.zig index 5087ec371..22464b4da 100644 --- a/src/js_parser/js_parser.zig +++ b/src/js_parser/js_parser.zig @@ -7780,9 +7780,13 @@ pub fn NewParser( // Destructuring patterns have an optional default value var initializer: ?Expr = null; if (errors != null and p.lexer.token == .t_equals) { - (errors orelse unreachable).invalid_expr_default_value = p.lexer.range(); + const invalid_expr_default_value_range = p.lexer.range(); try p.lexer.next(); initializer = try p.parseExpr(.comma); + // ({foo: 1 = }) + // ^ is invalid + // but it's only invalid if we're missing an expression here. + if (initializer == null) errors.?.invalid_expr_default_value = invalid_expr_default_value_range; } return G.Property{ |