diff --git a/es2panda/parser/statementParser.cpp b/es2panda/parser/statementParser.cpp index b9c73c0ad85f75fccc6d04d60996a78efc32f5c3..92917ba74cd9ae177bc89a2eb44993afb1628fe5 100644 --- a/es2panda/parser/statementParser.cpp +++ b/es2panda/parser/statementParser.cpp @@ -1045,7 +1045,7 @@ ir::ContinueStatement *ParserImpl::ParseContinueStatement() const auto &label = lexer_->GetToken().Ident(); const ParserContext *labelCtx = context_.FindLabel(label); - if (!labelCtx || !(labelCtx->Status() & ParserStatus::IN_ITERATION) || + if (!labelCtx || !(labelCtx->Status() & (ParserStatus::IN_ITERATION | ParserStatus::IN_LABELED)) || (labelCtx->Status() & ParserStatus::DISALLOW_CONTINUE)) { ThrowSyntaxError("Undefined label"); } diff --git a/es2panda/test/compiler/js/language/statements/labeled/test-labeled-iteration-continue-target-expected.txt b/es2panda/test/compiler/js/language/statements/labeled/test-labeled-iteration-continue-target-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..9766475a4185a151dc9d56d614ffb9aaea3bfd42 --- /dev/null +++ b/es2panda/test/compiler/js/language/statements/labeled/test-labeled-iteration-continue-target-expected.txt @@ -0,0 +1 @@ +ok diff --git a/es2panda/test/compiler/js/language/statements/labeled/test-labeled-iteration-continue-target.js b/es2panda/test/compiler/js/language/statements/labeled/test-labeled-iteration-continue-target.js new file mode 100644 index 0000000000000000000000000000000000000000..3aeb237278d571ae8377417280ef3a9515742e88 --- /dev/null +++ b/es2panda/test/compiler/js/language/statements/labeled/test-labeled-iteration-continue-target.js @@ -0,0 +1,7 @@ +let a = 1; +target1: +target2: +while(a--) { + continue target1; +} +print("ok"); \ No newline at end of file diff --git a/es2panda/test/parser/js/test-labeled-iteration-continue-target-expected.txt b/es2panda/test/parser/js/test-labeled-iteration-continue-target-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6f1d4caf172c20ade4efcd5d4b3af9582794f636 --- /dev/null +++ b/es2panda/test/parser/js/test-labeled-iteration-continue-target-expected.txt @@ -0,0 +1,210 @@ +{ + "type": "Program", + "statements": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "a", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + } + }, + "init": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 10 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 11 + } + } + }, + { + "type": "LabelledStatement", + "label": { + "type": "Identifier", + "name": "target1", + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 8 + } + } + }, + "body": { + "type": "LabelledStatement", + "label": { + "type": "Identifier", + "name": "target2", + "loc": { + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 3, + "column": 8 + } + } + }, + "body": { + "type": "WhileStatement", + "test": { + "type": "UpdateExpression", + "operator": "--", + "prefix": false, + "argument": { + "type": "Identifier", + "name": "a", + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 8 + } + } + }, + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 10 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ContinueStatement", + "label": { + "type": "Identifier", + "name": "target1", + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 21 + } + } + }, + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 22 + } + } + } + ], + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 6, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 6, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 6, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 6, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 6, + "column": 2 + } + } +} diff --git a/es2panda/test/parser/js/test-labeled-iteration-continue-target.js b/es2panda/test/parser/js/test-labeled-iteration-continue-target.js new file mode 100644 index 0000000000000000000000000000000000000000..56b1b14efc55d637cdbd37c55ce12f6805771522 --- /dev/null +++ b/es2panda/test/parser/js/test-labeled-iteration-continue-target.js @@ -0,0 +1,6 @@ +let a = 1; +target1: +target2: +while(a--) { + continue target1; +} \ No newline at end of file diff --git a/es2panda/test/test_tsc_ignore_list.txt b/es2panda/test/test_tsc_ignore_list.txt index 8c112aa8bc9d092e8ea0e379b2b61aba9bb8640e..64fbe477b659e1dfac5cff2135f5af139ad942d4 100644 --- a/es2panda/test/test_tsc_ignore_list.txt +++ b/es2panda/test/test_tsc_ignore_list.txt @@ -5,7 +5,6 @@ es2panda/test/TypeScript/tests/cases/compiler/collisionArgumentsInType.ts es2panda/test/TypeScript/tests/cases/compiler/collisionArgumentsInterfaceMembers.ts es2panda/test/TypeScript/tests/cases/compiler/computedPropertiesTransformedInOtherwiseNonTSClasses.ts es2panda/test/TypeScript/tests/cases/compiler/constructorOverloads5.ts -es2panda/test/TypeScript/tests/cases/compiler/continueTarget3.ts es2panda/test/TypeScript/tests/cases/compiler/elidedEmbeddedStatementsReplacedWithSemicolon.ts es2panda/test/TypeScript/tests/cases/compiler/emitBundleWithShebang1.ts es2panda/test/TypeScript/tests/cases/compiler/exportAsNamespace.d.ts @@ -73,7 +72,6 @@ es2panda/test/TypeScript/tests/cases/conformance/interfaces/interfaceDeclaration es2panda/test/TypeScript/tests/cases/conformance/interfaces/interfaceDeclarations/asiPreventsParsingAsInterface03.ts es2panda/test/TypeScript/tests/cases/conformance/interfaces/interfaceDeclarations/asiPreventsParsingAsInterface04.ts es2panda/test/TypeScript/tests/cases/conformance/parser/ecmascript5/RegressionTests/parser579071.ts -es2panda/test/TypeScript/tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueTarget3.ts es2panda/test/TypeScript/tests/cases/conformance/parser/ecmascript5/parserUnicodeWhitespaceCharacter1.ts es2panda/test/TypeScript/tests/cases/conformance/scanner/ecmascript3/scannerES3NumericLiteral2.ts es2panda/test/TypeScript/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts