diff --git a/common.gypi b/common.gypi index 2145192e71f..93b20503c4c 100644 --- a/common.gypi +++ b/common.gypi @@ -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.9', + 'v8_embedder_string': '-node.10', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/parsing/parser-base.h b/deps/v8/src/parsing/parser-base.h index b11f1d683f8..55452b28675 100644 --- a/deps/v8/src/parsing/parser-base.h +++ b/deps/v8/src/parsing/parser-base.h @@ -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 diff --git a/deps/v8/test/test262/test262.status b/deps/v8/test/test262/test262.status index 6791f788611..87244eb314a 100644 --- a/deps/v8/test/test262/test262.status +++ b/deps/v8/test/test262/test262.status @@ -1271,6 +1271,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], diff --git a/deps/v8/test/unittests/parser/decls-unittest.cc b/deps/v8/test/unittests/parser/decls-unittest.cc index 86ffdc35029..f1f8cad98a4 100644 --- a/deps/v8/test/unittests/parser/decls-unittest.cc +++ b/deps/v8/test/unittests/parser/decls-unittest.cc @@ -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); } }