Skip to content

deps: V8: cherry-pick 249de887a8d3 #58561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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 common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.12',
'v8_embedder_string': '-node.13',

##### V8 defaults for Node.js #####

Expand Down
22 changes: 16 additions & 6 deletions deps/v8/src/parsing/parser-base.h
Original file line number Diff line number Diff line change
Expand Up @@ -1178,15 +1178,16 @@ class ParserBase {
scope()->scope_type() == REPL_MODE_SCOPE) &&
!scope()->is_nonlinear());
}
bool IsNextUsingKeyword(Token::Value token_after_using, bool is_await_using) {
bool IsNextUsingKeyword(bool is_await_using) {
// using and await using declarations in for-of statements must be followed
// by a non-pattern ForBinding. In the case of synchronous `using`, `of` is
// disallowed as well with a negative lookahead.
// by a non-pattern ForBinding.
//
// `of`: for ( [lookahead ≠ using of] ForDeclaration[?Yield, ?Await, +Using]
// of AssignmentExpression[+In, ?Yield, ?Await] )
//
// If `using` is not considered a keyword, it is parsed as an identifier.
Token::Value token_after_using =
is_await_using ? PeekAheadAhead() : PeekAhead();
if (v8_flags.js_explicit_resource_management) {
switch (token_after_using) {
case Token::kIdentifier:
Expand All @@ -1201,7 +1202,16 @@ class ParserBase {
case Token::kAsync:
return true;
case Token::kOf:
return is_await_using;
if (is_await_using) {
return true;
} else {
// In the case of synchronous `using`, `of` is disallowed as well
// with a negative lookahead for for-of loops. But, cursedly,
// `using of` is allowed as the initializer of C-style for loops,
// e.g. `for (using of = null;;)` parses.
Token::Value token_after_of = PeekAheadAhead();
return token_after_of == Token::kAssign;
}
case Token::kFutureStrictReservedWord:
case Token::kEscapedStrictReservedWord:
return is_sloppy(language_mode());
Expand All @@ -1220,12 +1230,12 @@ class ParserBase {
// LineTerminator here] ForBinding[?Yield, +Await, ~Pattern]
return ((peek() == Token::kUsing &&
!scanner()->HasLineTerminatorAfterNext() &&
IsNextUsingKeyword(PeekAhead(), /* is_await_using */ false)) ||
IsNextUsingKeyword(/* is_await_using */ false)) ||
(is_await_allowed() && peek() == Token::kAwait &&
!scanner()->HasLineTerminatorAfterNext() &&
PeekAhead() == Token::kUsing &&
!scanner()->HasLineTerminatorAfterNextNext() &&
IsNextUsingKeyword(PeekAheadAhead(), /* is_await_using */ true)));
IsNextUsingKeyword(/* is_await_using */ true)));
}
const PendingCompilationErrorHandler* pending_error_handler() const {
return pending_error_handler_;
Expand Down
2 changes: 2 additions & 0 deletions deps/v8/test/mjsunit/harmony/for-using-of-await-using-of.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,6 @@ const reservedWords =
for (using using of[]) {}
for (using async of []) {}
for (using foo of []) {}
// Cursedly, `using of` is a valid binding form in C-style for loops.
for (using of = null;;) break;
})();
Loading