aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-08-11 16:22:08 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-08-11 16:22:08 -0700
commit3c6d687423b237d0c5b4d9a01e809a3b0bf6bac6 (patch)
tree87956420ac524b8f74e33cbd66749891fd3ab7c1
parentc3c14ff9ce2c8e02ee09b44d3f17a063d2d37ff2 (diff)
downloadbun-3c6d687423b237d0c5b4d9a01e809a3b0bf6bac6.tar.gz
bun-3c6d687423b237d0c5b4d9a01e809a3b0bf6bac6.tar.zst
bun-3c6d687423b237d0c5b4d9a01e809a3b0bf6bac6.zip
Fix missing check for is_async in shorthand property check
Former-commit-id: 8f2f739bcb303e0ca42853097449133a1630debe
-rw-r--r--src/js_parser/js_parser.zig3
-rw-r--r--src/test/fixtures/module_exports_with_default_values.js1
2 files changed, 3 insertions, 1 deletions
diff --git a/src/js_parser/js_parser.zig b/src/js_parser/js_parser.zig
index c341300c7..5087ec371 100644
--- a/src/js_parser/js_parser.zig
+++ b/src/js_parser/js_parser.zig
@@ -7767,7 +7767,8 @@ pub fn NewParser(
key = p.e(E.String{ .utf8 = name }, name_range.loc);
// Parse a shorthand property
- if (!opts.is_class and kind == .normal and p.lexer.token != .t_colon and p.lexer.token != .t_open_paren and p.lexer.token != .t_less_than and !opts.is_generator and !js_lexer.Keywords.has(name)) {
+ const isShorthandProperty = (!opts.is_class and kind == .normal and p.lexer.token != .t_colon and p.lexer.token != .t_open_paren and p.lexer.token != .t_less_than and !opts.is_generator and !opts.is_async and !js_lexer.Keywords.has(name));
+ if (isShorthandProperty) {
if ((p.fn_or_arrow_data_parse.allow_await != .allow_ident and strings.eqlComptime(name, "await")) or (p.fn_or_arrow_data_parse.allow_yield != .allow_ident and strings.eqlComptime(name, "yield"))) {
// TODO: add fmt to addRangeError
p.log.addRangeError(p.source, name_range, "Cannot use \"yield\" or \"await\" here.") catch unreachable;
diff --git a/src/test/fixtures/module_exports_with_default_values.js b/src/test/fixtures/module_exports_with_default_values.js
new file mode 100644
index 000000000..56669f109
--- /dev/null
+++ b/src/test/fixtures/module_exports_with_default_values.js
@@ -0,0 +1 @@
+module.exports = ({ level = "info", debug = false, console }) => {};