mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
deps: V8: cherry-pick 044b9b6f589d
Original commit message: [explicit-resource-management] disallow using in switch cases This CL disallows `using` and `await using` in switch cases. This was a normative change that got consensus in TC39 meetings: https://github.com/rbuckton/ecma262/pull/14 Bug: 409478039 Change-Id: I077e75d7d0d632c8b34150cfc76e4903984d6091 Reviewed-on:6500234
Reviewed-by: Shu-yu Guo <syg@chromium.org> Commit-Queue: Rezvan Mahdavi Hezaveh <rezvan@chromium.org> Cr-Commit-Position: refs/heads/main@{#100037} Refs:044b9b6f58
PR-URL: https://github.com/nodejs/node/pull/58230 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This commit is contained in:
parent
12e0b51c53
commit
c8f82953bb
4 changed files with 43 additions and 8 deletions
|
@ -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.13',
|
||||
'v8_embedder_string': '-node.14',
|
||||
|
||||
##### V8 defaults for Node.js #####
|
||||
|
||||
|
|
16
deps/v8/src/parsing/parser-base.h
vendored
16
deps/v8/src/parsing/parser-base.h
vendored
|
@ -1165,16 +1165,18 @@ class ParserBase {
|
|||
}
|
||||
bool is_using_allowed() const {
|
||||
// UsingDeclaration and AwaitUsingDeclaration are Syntax Errors if the goal
|
||||
// symbol is Script. UsingDeclaration and AwaitUsingDeclaration are not
|
||||
// contained, either directly or indirectly, within a Block, CaseBlock,
|
||||
// ForStatement, ForInOfStatement, FunctionBody, GeneratorBody,
|
||||
// symbol is Script. UsingDeclaration and AwaitUsingDeclaration are Syntax
|
||||
// Errors if they are not contained, either directly or indirectly, within a
|
||||
// Block, ForStatement, ForInOfStatement, FunctionBody, GeneratorBody,
|
||||
// AsyncGeneratorBody, AsyncFunctionBody, ClassStaticBlockBody, or
|
||||
// ClassBody. Unless the current scope's ScopeType is ScriptScope, the
|
||||
// ClassBody. They are disallowed in 'bare' switch cases.
|
||||
// Unless the current scope's ScopeType is ScriptScope, the
|
||||
// current position is directly or indirectly within one of the productions
|
||||
// listed above since they open a new scope.
|
||||
return ((scope()->scope_type() != SCRIPT_SCOPE &&
|
||||
scope()->scope_type() != EVAL_SCOPE) ||
|
||||
scope()->scope_type() == REPL_MODE_SCOPE);
|
||||
return (((scope()->scope_type() != SCRIPT_SCOPE &&
|
||||
scope()->scope_type() != EVAL_SCOPE) ||
|
||||
scope()->scope_type() == REPL_MODE_SCOPE) &&
|
||||
!scope()->is_nonlinear());
|
||||
}
|
||||
bool IsNextUsingKeyword(Token::Value token_after_using, bool is_await_using) {
|
||||
// using and await using declarations in for-of statements must be followed
|
||||
|
|
4
deps/v8/test/test262/test262.status
vendored
4
deps/v8/test/test262/test262.status
vendored
|
@ -1277,6 +1277,10 @@
|
|||
# May OOM fatally
|
||||
'staging/sm/regress/regress-610026': [SKIP],
|
||||
|
||||
# https://github.com/rbuckton/ecma262/pull/14
|
||||
'staging/explicit-resource-management/await-using-in-switch-case-block': [SKIP],
|
||||
'staging/explicit-resource-management/call-dispose-methods': [SKIP],
|
||||
|
||||
############################ SLOW TESTS #############################
|
||||
|
||||
'annexB/built-ins/RegExp/RegExp-leading-escape-BMP': [PASS, SLOW],
|
||||
|
|
29
deps/v8/test/unittests/parser/decls-unittest.cc
vendored
29
deps/v8/test/unittests/parser/decls-unittest.cc
vendored
|
@ -1082,6 +1082,24 @@ TEST_F(DeclsTest, TestUsing) {
|
|||
EXPECT_ERROR);
|
||||
context.Check("{var using; \n using = 42;}", EXPECT_RESULT,
|
||||
Number::New(isolate(), 42));
|
||||
context.Check(
|
||||
"let label = \"1\"; \n switch (label) { \n case 1: \n let y = 2; \n"
|
||||
"using x = { \n "
|
||||
" value: 1, \n "
|
||||
" [Symbol.dispose]() { \n "
|
||||
" return 42; \n "
|
||||
" } \n "
|
||||
" }; }",
|
||||
EXPECT_ERROR);
|
||||
context.Check(
|
||||
"let label = \"1\"; \n switch (label) { \n case 1: {\n let y = 2; \n"
|
||||
"using x = { \n "
|
||||
" value: 1, \n "
|
||||
" [Symbol.dispose]() { \n "
|
||||
" return 42; \n "
|
||||
" } \n "
|
||||
" }; } }",
|
||||
EXPECT_RESULT, Undefined(isolate()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1144,6 +1162,17 @@ TEST_F(DeclsTest, TestAwaitUsing) {
|
|||
" } } \n "
|
||||
" f(); ",
|
||||
EXPECT_ERROR);
|
||||
context.Check(
|
||||
"async function f() {let label = \"1\"; \n switch (label){ \n case 1: "
|
||||
"\n let y = 2;"
|
||||
"\n await using x = { \n "
|
||||
" value: 1, \n "
|
||||
" [Symbol.asyncDispose]() { \n "
|
||||
" classStaticBlockBodyValues.push(42); \n "
|
||||
" } \n "
|
||||
" }; \n }"
|
||||
"} \n f();",
|
||||
EXPECT_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue