Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/js_parser/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -916,10 +916,10 @@
},
token_range.loc,
)),
decls: decls_slice,
});
}
let r = p.store_name_in_ref(raw)?;
let r = p.store_name_in_ref(raw2)?;

Check notice on line 922 in src/js_parser/parse/mod.rs

View check run for this annotation

Claude / Claude Code Review

Missing [no LineTerminator here] check between 'await' and 'using'

Pre-existing (not introduced here, and matches esbuild/TS): the entry condition at line 885 doesn't check `!p.lexer.has_newline_before`, so `await\nusing x = y` is accepted as an `await using` declaration. Per the spec's `AwaitUsingDeclarationHead : await [no LineTerminator here] using` refinement + must-cover early error this should be a **SyntaxError** (V8 rejects it). Since you're already in this block, an optional follow-up would be adding `&& !p.lexer.has_newline_before` at line 885 — but i
Comment thread
robobun marked this conversation as resolved.
Comment thread
robobun marked this conversation as resolved.
Comment thread
robobun marked this conversation as resolved.
break 'value p.new_expr(
E::Identifier {
ref_: r,
Expand Down
23 changes: 23 additions & 0 deletions test/bundler/transpiler/transpiler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3824,6 +3824,29 @@ console.log("boop");
expectCapturePrintedSnapshot(`for await (await using a of b) { c(a); a(c) }`);
});

it("await of the identifier 'using' is not an await using declaration", () => {
// "await using" only starts a declaration when followed by an identifier on
// the same line. Otherwise it's an "await" expression of the identifier "using".
expectPrinted_(
"async function f() { await using instanceof o }",
"async function f() {\n await using instanceof o;\n}",
);
expectPrinted_("async function f() { await using }", "async function f() {\n await using;\n}");
expectPrinted_(
"async function f() { await using\n x = 1 }",
"async function f() {\n await using;\n x = 1;\n}",
);
expectPrinted_(
"async function f() { await using.foo() }",
"async function f() {\n await using.foo();\n}",
);
expectPrinted_(
"async function f() { for (await using instanceof o;;); }",
"async function f() {\n for (await using instanceof o;; )\n ;\n}",
);
expectBunPrinted_("await using instanceof o", "await using instanceof o");
});

it("using top level", () => {
expectPrintedSnapshot(`
using a = b;
Expand Down
Loading