From e931bcce204bb6f6049483521793efa354378af1 Mon Sep 17 00:00:00 2001 From: Mvmo Date: Sat, 8 Jul 2023 03:41:28 +0200 Subject: [PATCH 1/9] fix: appropriate error message for out of scope label --- src/compiler/checker.ts | 3 +++ src/compiler/diagnosticMessages.json | 4 ++++ tests/baselines/reference/breakTarget5.errors.txt | 4 ++-- tests/baselines/reference/classStaticBlock8.errors.txt | 8 ++++---- .../reference/continueNotInIterationStatement4.errors.txt | 4 ++-- tests/baselines/reference/continueTarget5.errors.txt | 4 ++-- .../reference/invalidDoWhileBreakStatements.errors.txt | 8 ++++---- .../reference/invalidDoWhileContinueStatements.errors.txt | 8 ++++---- .../reference/invalidForBreakStatements.errors.txt | 8 ++++---- .../reference/invalidForContinueStatements.errors.txt | 8 ++++---- .../reference/invalidForInBreakStatements.errors.txt | 8 ++++---- .../reference/invalidForInContinueStatements.errors.txt | 8 ++++---- .../reference/invalidWhileBreakStatements.errors.txt | 8 ++++---- .../reference/invalidWhileContinueStatements.errors.txt | 8 ++++---- tests/baselines/reference/parser_breakTarget5.errors.txt | 4 ++-- .../parser_continueNotInIterationStatement4.errors.txt | 4 ++-- .../baselines/reference/parser_continueTarget5.errors.txt | 4 ++-- tests/baselines/reference/plainJSBinderErrors.errors.txt | 5 +---- tests/baselines/reference/plainJSGrammarErrors.errors.txt | 8 +------- 19 files changed, 57 insertions(+), 59 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b8bdbacd73f42..4dd96584925c2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -48423,6 +48423,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { let current: Node = node; while (current) { if (isFunctionLikeOrClassStaticBlockDeclaration(current)) { + if (node.label) { + return grammarErrorOnNode(node, Diagnostics.Cannot_find_label_0, node.label.escapedText.toString()) + } return grammarErrorOnNode(node, Diagnostics.Jump_target_cannot_cross_function_boundary); } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index e15199127169c..851b5b44f6db9 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -7864,5 +7864,9 @@ "'await using' statements cannot be used inside a class static block.": { "category": "Error", "code": 18054 + }, + "Cannot find label '{0}'.": { + "category": "Error", + "code": 18055 } } diff --git a/tests/baselines/reference/breakTarget5.errors.txt b/tests/baselines/reference/breakTarget5.errors.txt index b842116ccca78..cfeb84cc121f2 100644 --- a/tests/baselines/reference/breakTarget5.errors.txt +++ b/tests/baselines/reference/breakTarget5.errors.txt @@ -1,4 +1,4 @@ -breakTarget5.ts(5,7): error TS1107: Jump target cannot cross function boundary. +breakTarget5.ts(5,7): error TS18055: Cannot find label 'target'. ==== breakTarget5.ts (1 errors) ==== @@ -8,7 +8,7 @@ breakTarget5.ts(5,7): error TS1107: Jump target cannot cross function boundary. while (true) { break target; ~~~~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. +!!! error TS18055: Cannot find label 'target'. } } } \ No newline at end of file diff --git a/tests/baselines/reference/classStaticBlock8.errors.txt b/tests/baselines/reference/classStaticBlock8.errors.txt index 9dab71ffc8217..632cfdb94f750 100644 --- a/tests/baselines/reference/classStaticBlock8.errors.txt +++ b/tests/baselines/reference/classStaticBlock8.errors.txt @@ -1,5 +1,5 @@ -classStaticBlock8.ts(6,21): error TS1107: Jump target cannot cross function boundary. -classStaticBlock8.ts(9,21): error TS1107: Jump target cannot cross function boundary. +classStaticBlock8.ts(6,21): error TS18055: Cannot find label 'label'. +classStaticBlock8.ts(9,21): error TS18055: Cannot find label 'label'. classStaticBlock8.ts(12,21): error TS1107: Jump target cannot cross function boundary. classStaticBlock8.ts(15,21): error TS1107: Jump target cannot cross function boundary. @@ -12,12 +12,12 @@ classStaticBlock8.ts(15,21): error TS1107: Jump target cannot cross function bou if (v === 1) { break label; ~~~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. +!!! error TS18055: Cannot find label 'label'. } if (v === 2) { continue label; ~~~~~~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. +!!! error TS18055: Cannot find label 'label'. } if (v === 3) { break diff --git a/tests/baselines/reference/continueNotInIterationStatement4.errors.txt b/tests/baselines/reference/continueNotInIterationStatement4.errors.txt index a4e72cb4eb9c7..969dd957eeb6d 100644 --- a/tests/baselines/reference/continueNotInIterationStatement4.errors.txt +++ b/tests/baselines/reference/continueNotInIterationStatement4.errors.txt @@ -1,4 +1,4 @@ -continueNotInIterationStatement4.ts(4,5): error TS1107: Jump target cannot cross function boundary. +continueNotInIterationStatement4.ts(4,5): error TS18055: Cannot find label 'TWO'. ==== continueNotInIterationStatement4.ts (1 errors) ==== @@ -7,7 +7,7 @@ continueNotInIterationStatement4.ts(4,5): error TS1107: Jump target cannot cross var x = () => { continue TWO; ~~~~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. +!!! error TS18055: Cannot find label 'TWO'. } } \ No newline at end of file diff --git a/tests/baselines/reference/continueTarget5.errors.txt b/tests/baselines/reference/continueTarget5.errors.txt index 64e5270ac83f1..f2b0ac22b52fb 100644 --- a/tests/baselines/reference/continueTarget5.errors.txt +++ b/tests/baselines/reference/continueTarget5.errors.txt @@ -1,4 +1,4 @@ -continueTarget5.ts(5,7): error TS1107: Jump target cannot cross function boundary. +continueTarget5.ts(5,7): error TS18055: Cannot find label 'target'. ==== continueTarget5.ts (1 errors) ==== @@ -8,7 +8,7 @@ continueTarget5.ts(5,7): error TS1107: Jump target cannot cross function boundar while (true) { continue target; ~~~~~~~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. +!!! error TS18055: Cannot find label 'target'. } } } \ No newline at end of file diff --git a/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt b/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt index 3e231d553b63b..750579696434c 100644 --- a/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt @@ -1,7 +1,7 @@ invalidDoWhileBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. invalidDoWhileBreakStatements.ts(8,4): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -invalidDoWhileBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. -invalidDoWhileBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. +invalidDoWhileBreakStatements.ts(14,9): error TS18055: Cannot find label 'TWO'. +invalidDoWhileBreakStatements.ts(21,9): error TS18055: Cannot find label 'THREE'. invalidDoWhileBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. invalidDoWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. @@ -26,7 +26,7 @@ invalidDoWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can on var x = () => { break TWO; ~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. +!!! error TS18055: Cannot find label 'TWO'. } }while (true) @@ -35,7 +35,7 @@ invalidDoWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can on var fn = function () { break THREE; ~~~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. +!!! error TS18055: Cannot find label 'THREE'. } }while (true) diff --git a/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt b/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt index 33a60d7f45fe5..7098b4f38a3db 100644 --- a/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt @@ -1,7 +1,7 @@ invalidDoWhileContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. invalidDoWhileContinueStatements.ts(8,4): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -invalidDoWhileContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. -invalidDoWhileContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. +invalidDoWhileContinueStatements.ts(14,9): error TS18055: Cannot find label 'TWO'. +invalidDoWhileContinueStatements.ts(21,9): error TS18055: Cannot find label 'THREE'. invalidDoWhileContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. invalidDoWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. @@ -26,7 +26,7 @@ invalidDoWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement var x = () => { continue TWO; ~~~~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. +!!! error TS18055: Cannot find label 'TWO'. } }while (true) @@ -35,7 +35,7 @@ invalidDoWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement var fn = function () { continue THREE; ~~~~~~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. +!!! error TS18055: Cannot find label 'THREE'. } }while (true) diff --git a/tests/baselines/reference/invalidForBreakStatements.errors.txt b/tests/baselines/reference/invalidForBreakStatements.errors.txt index 099663ea32f24..799258e221895 100644 --- a/tests/baselines/reference/invalidForBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidForBreakStatements.errors.txt @@ -1,7 +1,7 @@ invalidForBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. invalidForBreakStatements.ts(8,9): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -invalidForBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. -invalidForBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. +invalidForBreakStatements.ts(14,9): error TS18055: Cannot find label 'TWO'. +invalidForBreakStatements.ts(21,9): error TS18055: Cannot find label 'THREE'. invalidForBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. invalidForBreakStatements.ts(36,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. @@ -26,7 +26,7 @@ invalidForBreakStatements.ts(36,5): error TS1116: A 'break' statement can only j var x = () => { break TWO; ~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. +!!! error TS18055: Cannot find label 'TWO'. } } @@ -35,7 +35,7 @@ invalidForBreakStatements.ts(36,5): error TS1116: A 'break' statement can only j var fn = function () { break THREE; ~~~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. +!!! error TS18055: Cannot find label 'THREE'. } } diff --git a/tests/baselines/reference/invalidForContinueStatements.errors.txt b/tests/baselines/reference/invalidForContinueStatements.errors.txt index a13982e633c23..77f8e96cf1554 100644 --- a/tests/baselines/reference/invalidForContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidForContinueStatements.errors.txt @@ -1,7 +1,7 @@ invalidForContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. invalidForContinueStatements.ts(8,9): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -invalidForContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. -invalidForContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. +invalidForContinueStatements.ts(14,9): error TS18055: Cannot find label 'TWO'. +invalidForContinueStatements.ts(21,9): error TS18055: Cannot find label 'THREE'. invalidForContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. invalidForContinueStatements.ts(36,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. @@ -26,7 +26,7 @@ invalidForContinueStatements.ts(36,5): error TS1115: A 'continue' statement can var x = () => { continue TWO; ~~~~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. +!!! error TS18055: Cannot find label 'TWO'. } } @@ -35,7 +35,7 @@ invalidForContinueStatements.ts(36,5): error TS1115: A 'continue' statement can var fn = function () { continue THREE; ~~~~~~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. +!!! error TS18055: Cannot find label 'THREE'. } } diff --git a/tests/baselines/reference/invalidForInBreakStatements.errors.txt b/tests/baselines/reference/invalidForInBreakStatements.errors.txt index 373d9bf99df21..46583e0f67139 100644 --- a/tests/baselines/reference/invalidForInBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidForInBreakStatements.errors.txt @@ -1,7 +1,7 @@ invalidForInBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. invalidForInBreakStatements.ts(8,19): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -invalidForInBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. -invalidForInBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. +invalidForInBreakStatements.ts(14,9): error TS18055: Cannot find label 'TWO'. +invalidForInBreakStatements.ts(21,9): error TS18055: Cannot find label 'THREE'. invalidForInBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. invalidForInBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. @@ -26,7 +26,7 @@ invalidForInBreakStatements.ts(37,5): error TS1116: A 'break' statement can only var fn = () => { break TWO; ~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. +!!! error TS18055: Cannot find label 'TWO'. } } @@ -35,7 +35,7 @@ invalidForInBreakStatements.ts(37,5): error TS1116: A 'break' statement can only var fn = function () { break THREE; ~~~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. +!!! error TS18055: Cannot find label 'THREE'. } } diff --git a/tests/baselines/reference/invalidForInContinueStatements.errors.txt b/tests/baselines/reference/invalidForInContinueStatements.errors.txt index 71e765d3fa114..98a9c3f87626f 100644 --- a/tests/baselines/reference/invalidForInContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidForInContinueStatements.errors.txt @@ -1,7 +1,7 @@ invalidForInContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. invalidForInContinueStatements.ts(8,19): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -invalidForInContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. -invalidForInContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. +invalidForInContinueStatements.ts(14,9): error TS18055: Cannot find label 'TWO'. +invalidForInContinueStatements.ts(21,9): error TS18055: Cannot find label 'THREE'. invalidForInContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. invalidForInContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. @@ -26,7 +26,7 @@ invalidForInContinueStatements.ts(37,5): error TS1115: A 'continue' statement ca var fn = () => { continue TWO; ~~~~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. +!!! error TS18055: Cannot find label 'TWO'. } } @@ -35,7 +35,7 @@ invalidForInContinueStatements.ts(37,5): error TS1115: A 'continue' statement ca var fn = function () { continue THREE; ~~~~~~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. +!!! error TS18055: Cannot find label 'THREE'. } } diff --git a/tests/baselines/reference/invalidWhileBreakStatements.errors.txt b/tests/baselines/reference/invalidWhileBreakStatements.errors.txt index b93a32288b213..f79fd675fcc7f 100644 --- a/tests/baselines/reference/invalidWhileBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidWhileBreakStatements.errors.txt @@ -1,7 +1,7 @@ invalidWhileBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. invalidWhileBreakStatements.ts(8,14): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -invalidWhileBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. -invalidWhileBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. +invalidWhileBreakStatements.ts(14,9): error TS18055: Cannot find label 'TWO'. +invalidWhileBreakStatements.ts(21,9): error TS18055: Cannot find label 'THREE'. invalidWhileBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. invalidWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. @@ -26,7 +26,7 @@ invalidWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only var x = () => { break TWO; ~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. +!!! error TS18055: Cannot find label 'TWO'. } } @@ -35,7 +35,7 @@ invalidWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only var fn = function () { break THREE; ~~~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. +!!! error TS18055: Cannot find label 'THREE'. } } diff --git a/tests/baselines/reference/invalidWhileContinueStatements.errors.txt b/tests/baselines/reference/invalidWhileContinueStatements.errors.txt index e49c679e83f42..1ed166ec8643f 100644 --- a/tests/baselines/reference/invalidWhileContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidWhileContinueStatements.errors.txt @@ -1,7 +1,7 @@ invalidWhileContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. invalidWhileContinueStatements.ts(8,14): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -invalidWhileContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. -invalidWhileContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. +invalidWhileContinueStatements.ts(14,9): error TS18055: Cannot find label 'TWO'. +invalidWhileContinueStatements.ts(21,9): error TS18055: Cannot find label 'THREE'. invalidWhileContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. invalidWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. @@ -26,7 +26,7 @@ invalidWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement ca var x = () => { continue TWO; ~~~~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. +!!! error TS18055: Cannot find label 'TWO'. } } @@ -35,7 +35,7 @@ invalidWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement ca var fn = function () { continue THREE; ~~~~~~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. +!!! error TS18055: Cannot find label 'THREE'. } } diff --git a/tests/baselines/reference/parser_breakTarget5.errors.txt b/tests/baselines/reference/parser_breakTarget5.errors.txt index 46eede4e845bc..d59480adc5c9f 100644 --- a/tests/baselines/reference/parser_breakTarget5.errors.txt +++ b/tests/baselines/reference/parser_breakTarget5.errors.txt @@ -1,4 +1,4 @@ -parser_breakTarget5.ts(5,7): error TS1107: Jump target cannot cross function boundary. +parser_breakTarget5.ts(5,7): error TS18055: Cannot find label 'target'. ==== parser_breakTarget5.ts (1 errors) ==== @@ -8,7 +8,7 @@ parser_breakTarget5.ts(5,7): error TS1107: Jump target cannot cross function bou while (true) { break target; ~~~~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. +!!! error TS18055: Cannot find label 'target'. } } } \ No newline at end of file diff --git a/tests/baselines/reference/parser_continueNotInIterationStatement4.errors.txt b/tests/baselines/reference/parser_continueNotInIterationStatement4.errors.txt index fd4b252fbd3d1..87af53ddd8c56 100644 --- a/tests/baselines/reference/parser_continueNotInIterationStatement4.errors.txt +++ b/tests/baselines/reference/parser_continueNotInIterationStatement4.errors.txt @@ -1,4 +1,4 @@ -parser_continueNotInIterationStatement4.ts(4,5): error TS1107: Jump target cannot cross function boundary. +parser_continueNotInIterationStatement4.ts(4,5): error TS18055: Cannot find label 'TWO'. ==== parser_continueNotInIterationStatement4.ts (1 errors) ==== @@ -7,7 +7,7 @@ parser_continueNotInIterationStatement4.ts(4,5): error TS1107: Jump target canno var x = () => { continue TWO; ~~~~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. +!!! error TS18055: Cannot find label 'TWO'. } } \ No newline at end of file diff --git a/tests/baselines/reference/parser_continueTarget5.errors.txt b/tests/baselines/reference/parser_continueTarget5.errors.txt index 1a80e2d9f968c..25439a10c2561 100644 --- a/tests/baselines/reference/parser_continueTarget5.errors.txt +++ b/tests/baselines/reference/parser_continueTarget5.errors.txt @@ -1,4 +1,4 @@ -parser_continueTarget5.ts(5,7): error TS1107: Jump target cannot cross function boundary. +parser_continueTarget5.ts(5,7): error TS18055: Cannot find label 'target'. ==== parser_continueTarget5.ts (1 errors) ==== @@ -8,7 +8,7 @@ parser_continueTarget5.ts(5,7): error TS1107: Jump target cannot cross function while (true) { continue target; ~~~~~~~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. +!!! error TS18055: Cannot find label 'target'. } } } \ No newline at end of file diff --git a/tests/baselines/reference/plainJSBinderErrors.errors.txt b/tests/baselines/reference/plainJSBinderErrors.errors.txt index 8eeeb92765ee6..f85e8202b609b 100644 --- a/tests/baselines/reference/plainJSBinderErrors.errors.txt +++ b/tests/baselines/reference/plainJSBinderErrors.errors.txt @@ -12,12 +12,11 @@ plainJSBinderErrors.js(22,15): error TS1210: Code contained in a class is evalua plainJSBinderErrors.js(23,15): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. plainJSBinderErrors.js(27,9): error TS1101: 'with' statements are not allowed in strict mode. plainJSBinderErrors.js(33,13): error TS1344: 'A label is not allowed here. -plainJSBinderErrors.js(34,13): error TS1107: Jump target cannot cross function boundary. plainJSBinderErrors.js(39,7): error TS1215: Invalid use of 'eval'. Modules are automatically in strict mode. plainJSBinderErrors.js(40,7): error TS1215: Invalid use of 'arguments'. Modules are automatically in strict mode. -==== plainJSBinderErrors.js (17 errors) ==== +==== plainJSBinderErrors.js (16 errors) ==== export default 12 ~~~~~~~~~~~~~~~~~ !!! error TS2528: A module cannot have multiple default exports. @@ -82,8 +81,6 @@ plainJSBinderErrors.js(40,7): error TS1215: Invalid use of 'arguments'. Modules ~~~~~ !!! error TS1344: 'A label is not allowed here. break label - ~~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. } return x } diff --git a/tests/baselines/reference/plainJSGrammarErrors.errors.txt b/tests/baselines/reference/plainJSGrammarErrors.errors.txt index 8b015217e305f..68bad2ae5fd57 100644 --- a/tests/baselines/reference/plainJSGrammarErrors.errors.txt +++ b/tests/baselines/reference/plainJSGrammarErrors.errors.txt @@ -88,9 +88,7 @@ plainJSGrammarErrors.js(154,5): error TS1113: A 'default' clause cannot appear m plainJSGrammarErrors.js(161,11): error TS2492: Cannot redeclare identifier 'e' in catch clause. plainJSGrammarErrors.js(167,12): error TS1197: Catch clause variable cannot have an initializer. plainJSGrammarErrors.js(170,5): error TS1114: Duplicate label 'label'. -plainJSGrammarErrors.js(179,13): error TS1107: Jump target cannot cross function boundary. plainJSGrammarErrors.js(187,13): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -plainJSGrammarErrors.js(191,5): error TS1107: Jump target cannot cross function boundary. plainJSGrammarErrors.js(194,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. plainJSGrammarErrors.js(195,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. plainJSGrammarErrors.js(197,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. @@ -102,7 +100,7 @@ plainJSGrammarErrors.js(204,30): message TS1450: Dynamic imports can only accept plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot be spread element. -==== plainJSGrammarErrors.js (102 errors) ==== +==== plainJSGrammarErrors.js (100 errors) ==== class C { // #private mistakes q = #unbound @@ -462,8 +460,6 @@ plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot outer: for(;;) { function test() { break outer - ~~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. } test() } @@ -478,8 +474,6 @@ plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot } function jumpToLabelOnly(x) { break jumpToLabelOnly - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1107: Jump target cannot cross function boundary. } for (;;) { break toplevel From fb73d538ae9a0c9655c27d74aa4013cec21235fd Mon Sep 17 00:00:00 2001 From: Mvmo Date: Sat, 8 Jul 2023 16:14:49 +0200 Subject: [PATCH 2/9] fix: code style - semicolon --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4dd96584925c2..787db5a6c6d14 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -48424,7 +48424,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { while (current) { if (isFunctionLikeOrClassStaticBlockDeclaration(current)) { if (node.label) { - return grammarErrorOnNode(node, Diagnostics.Cannot_find_label_0, node.label.escapedText.toString()) + return grammarErrorOnNode(node, Diagnostics.Cannot_find_label_0, node.label.escapedText.toString()); } return grammarErrorOnNode(node, Diagnostics.Jump_target_cannot_cross_function_boundary); } From 1071d916a720e32f4a0f1d0139015aa84ff595fe Mon Sep 17 00:00:00 2001 From: Mvmo Date: Tue, 1 Aug 2023 05:59:02 +0200 Subject: [PATCH 3/9] New error messages --- src/compiler/checker.ts | 23 ++++++++++++++++++- src/compiler/diagnosticMessages.json | 4 ++++ ...assStaticBlock26(target=es2022).errors.txt | 5 +++- ...assStaticBlock26(target=esnext).errors.txt | 5 +++- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 787db5a6c6d14..9aa4fc4b5b292 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -48424,8 +48424,29 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { while (current) { if (isFunctionLikeOrClassStaticBlockDeclaration(current)) { if (node.label) { - return grammarErrorOnNode(node, Diagnostics.Cannot_find_label_0, node.label.escapedText.toString()); + const diagnostic = createDiagnosticForNode(node, Diagnostics.Cannot_find_label_0, node.label.escapedText.toString()); + + const functionOrClassLike = current as FunctionLikeDeclaration | ClassStaticBlockDeclaration; + if (!functionOrClassLike.body) { + break; + } + + let matchingLabelLine: number | undefined; + forEachChild(functionOrClassLike.body, (childNode) => { + if (matchingLabelLine) { + return; + } + + const labeledStatement = childNode as LabeledStatement; + if (labeledStatement.kind === SyntaxKind.LabeledStatement && labeledStatement.label.escapedText === node.label!.escapedText) { + diagnostic.relatedInformation = [createDiagnosticForNode(labeledStatement, Diagnostics.Label_0_declared_after_usage, labeledStatement.label.escapedText.toString())]; + } + }); + + diagnostics.add(diagnostic); + return true; } + // mvmo return grammarErrorOnNode(node, Diagnostics.Jump_target_cannot_cross_function_boundary); } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 851b5b44f6db9..c76f400575d78 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -7868,5 +7868,9 @@ "Cannot find label '{0}'.": { "category": "Error", "code": 18055 + }, + "Label '{0}' declared after usage": { + "category": "Error", + "code": 18056 } } diff --git a/tests/baselines/reference/classStaticBlock26(target=es2022).errors.txt b/tests/baselines/reference/classStaticBlock26(target=es2022).errors.txt index 108e2368dad7f..9c886bd870c4a 100644 --- a/tests/baselines/reference/classStaticBlock26(target=es2022).errors.txt +++ b/tests/baselines/reference/classStaticBlock26(target=es2022).errors.txt @@ -8,6 +8,7 @@ classStaticBlock26.ts(13,19): error TS1109: Expression expected. classStaticBlock26.ts(17,18): error TS1005: ':' expected. classStaticBlock26.ts(20,9): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(20,14): error TS1109: Expression expected. +classStaticBlock26.ts(21,9): error TS18055: Cannot find label ''. classStaticBlock26.ts(21,15): error TS1003: Identifier expected. classStaticBlock26.ts(21,15): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(21,20): error TS1109: Expression expected. @@ -18,7 +19,7 @@ classStaticBlock26.ts(26,21): error TS18037: 'await' expression cannot be used i classStaticBlock26.ts(26,27): error TS1109: Expression expected. -==== classStaticBlock26.ts (18 errors) ==== +==== classStaticBlock26.ts (19 errors) ==== class C { static { await; // illegal @@ -60,6 +61,8 @@ classStaticBlock26.ts(26,27): error TS1109: Expression expected. ~ !!! error TS1109: Expression expected. break await; // illegal, 'await' cannot be used as a label + ~~~~~ +!!! error TS18055: Cannot find label ''. ~~~~~ !!! error TS1003: Identifier expected. ~~~~~ diff --git a/tests/baselines/reference/classStaticBlock26(target=esnext).errors.txt b/tests/baselines/reference/classStaticBlock26(target=esnext).errors.txt index 108e2368dad7f..9c886bd870c4a 100644 --- a/tests/baselines/reference/classStaticBlock26(target=esnext).errors.txt +++ b/tests/baselines/reference/classStaticBlock26(target=esnext).errors.txt @@ -8,6 +8,7 @@ classStaticBlock26.ts(13,19): error TS1109: Expression expected. classStaticBlock26.ts(17,18): error TS1005: ':' expected. classStaticBlock26.ts(20,9): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(20,14): error TS1109: Expression expected. +classStaticBlock26.ts(21,9): error TS18055: Cannot find label ''. classStaticBlock26.ts(21,15): error TS1003: Identifier expected. classStaticBlock26.ts(21,15): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(21,20): error TS1109: Expression expected. @@ -18,7 +19,7 @@ classStaticBlock26.ts(26,21): error TS18037: 'await' expression cannot be used i classStaticBlock26.ts(26,27): error TS1109: Expression expected. -==== classStaticBlock26.ts (18 errors) ==== +==== classStaticBlock26.ts (19 errors) ==== class C { static { await; // illegal @@ -60,6 +61,8 @@ classStaticBlock26.ts(26,27): error TS1109: Expression expected. ~ !!! error TS1109: Expression expected. break await; // illegal, 'await' cannot be used as a label + ~~~~~ +!!! error TS18055: Cannot find label ''. ~~~~~ !!! error TS1003: Identifier expected. ~~~~~ From 268c32543145d82a1a321c8f792a83ac44858f59 Mon Sep 17 00:00:00 2001 From: Mvmo Date: Tue, 1 Aug 2023 06:00:48 +0200 Subject: [PATCH 4/9] remove my code jump comment --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9aa4fc4b5b292..92500c0815640 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -48446,7 +48446,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { diagnostics.add(diagnostic); return true; } - // mvmo + return grammarErrorOnNode(node, Diagnostics.Jump_target_cannot_cross_function_boundary); } From 612ae78ed1dfb1c060ce623f1cf546d3e9ae4368 Mon Sep 17 00:00:00 2001 From: Mvmo Date: Wed, 2 Aug 2023 17:33:51 +0200 Subject: [PATCH 5/9] Update diagnostics --- src/compiler/checker.ts | 9 +++++---- src/compiler/diagnosticMessages.json | 4 ++-- tests/baselines/reference/breakTarget5.errors.txt | 4 ++-- .../classStaticBlock26(target=es2022).errors.txt | 4 ++-- .../classStaticBlock26(target=esnext).errors.txt | 4 ++-- tests/baselines/reference/classStaticBlock8.errors.txt | 8 ++++---- .../continueNotInIterationStatement4.errors.txt | 4 ++-- tests/baselines/reference/continueTarget5.errors.txt | 4 ++-- .../reference/invalidDoWhileBreakStatements.errors.txt | 8 ++++---- .../invalidDoWhileContinueStatements.errors.txt | 8 ++++---- .../reference/invalidForBreakStatements.errors.txt | 8 ++++---- .../reference/invalidForContinueStatements.errors.txt | 8 ++++---- .../reference/invalidForInBreakStatements.errors.txt | 8 ++++---- .../reference/invalidForInContinueStatements.errors.txt | 8 ++++---- .../reference/invalidWhileBreakStatements.errors.txt | 8 ++++---- .../reference/invalidWhileContinueStatements.errors.txt | 8 ++++---- tests/baselines/reference/parser_breakTarget5.errors.txt | 4 ++-- .../parser_continueNotInIterationStatement4.errors.txt | 4 ++-- .../reference/parser_continueTarget5.errors.txt | 4 ++-- 19 files changed, 59 insertions(+), 58 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 92500c0815640..a5a0af77bde72 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -48424,22 +48424,23 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { while (current) { if (isFunctionLikeOrClassStaticBlockDeclaration(current)) { if (node.label) { - const diagnostic = createDiagnosticForNode(node, Diagnostics.Cannot_find_label_0, node.label.escapedText.toString()); + const diagnostic = createDiagnosticForNode(node, Diagnostics.Label_0_used_before_declaration, node.label.escapedText.toString()); const functionOrClassLike = current as FunctionLikeDeclaration | ClassStaticBlockDeclaration; if (!functionOrClassLike.body) { break; } - let matchingLabelLine: number | undefined; + let matchingLabelDeclaration = false; forEachChild(functionOrClassLike.body, (childNode) => { - if (matchingLabelLine) { + if (matchingLabelDeclaration) { return; } const labeledStatement = childNode as LabeledStatement; if (labeledStatement.kind === SyntaxKind.LabeledStatement && labeledStatement.label.escapedText === node.label!.escapedText) { - diagnostic.relatedInformation = [createDiagnosticForNode(labeledStatement, Diagnostics.Label_0_declared_after_usage, labeledStatement.label.escapedText.toString())]; + diagnostic.relatedInformation = [createDiagnosticForNode(labeledStatement.label, Diagnostics.Label_defined_here, labeledStatement.label.escapedText.toString())]; + matchingLabelDeclaration = true; } }); diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index c76f400575d78..01074159dfac0 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -7865,11 +7865,11 @@ "category": "Error", "code": 18054 }, - "Cannot find label '{0}'.": { + "Label '{0}' used before declaration": { "category": "Error", "code": 18055 }, - "Label '{0}' declared after usage": { + "Label defined here": { "category": "Error", "code": 18056 } diff --git a/tests/baselines/reference/breakTarget5.errors.txt b/tests/baselines/reference/breakTarget5.errors.txt index cfeb84cc121f2..a976115c72923 100644 --- a/tests/baselines/reference/breakTarget5.errors.txt +++ b/tests/baselines/reference/breakTarget5.errors.txt @@ -1,4 +1,4 @@ -breakTarget5.ts(5,7): error TS18055: Cannot find label 'target'. +breakTarget5.ts(5,7): error TS18055: Label 'target' used before declaration ==== breakTarget5.ts (1 errors) ==== @@ -8,7 +8,7 @@ breakTarget5.ts(5,7): error TS18055: Cannot find label 'target'. while (true) { break target; ~~~~~~~~~~~~~ -!!! error TS18055: Cannot find label 'target'. +!!! error TS18055: Label 'target' used before declaration } } } \ No newline at end of file diff --git a/tests/baselines/reference/classStaticBlock26(target=es2022).errors.txt b/tests/baselines/reference/classStaticBlock26(target=es2022).errors.txt index 9c886bd870c4a..5cb5766797ae7 100644 --- a/tests/baselines/reference/classStaticBlock26(target=es2022).errors.txt +++ b/tests/baselines/reference/classStaticBlock26(target=es2022).errors.txt @@ -8,7 +8,7 @@ classStaticBlock26.ts(13,19): error TS1109: Expression expected. classStaticBlock26.ts(17,18): error TS1005: ':' expected. classStaticBlock26.ts(20,9): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(20,14): error TS1109: Expression expected. -classStaticBlock26.ts(21,9): error TS18055: Cannot find label ''. +classStaticBlock26.ts(21,9): error TS18055: Label '' used before declaration classStaticBlock26.ts(21,15): error TS1003: Identifier expected. classStaticBlock26.ts(21,15): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(21,20): error TS1109: Expression expected. @@ -62,7 +62,7 @@ classStaticBlock26.ts(26,27): error TS1109: Expression expected. !!! error TS1109: Expression expected. break await; // illegal, 'await' cannot be used as a label ~~~~~ -!!! error TS18055: Cannot find label ''. +!!! error TS18055: Label '' used before declaration ~~~~~ !!! error TS1003: Identifier expected. ~~~~~ diff --git a/tests/baselines/reference/classStaticBlock26(target=esnext).errors.txt b/tests/baselines/reference/classStaticBlock26(target=esnext).errors.txt index 9c886bd870c4a..5cb5766797ae7 100644 --- a/tests/baselines/reference/classStaticBlock26(target=esnext).errors.txt +++ b/tests/baselines/reference/classStaticBlock26(target=esnext).errors.txt @@ -8,7 +8,7 @@ classStaticBlock26.ts(13,19): error TS1109: Expression expected. classStaticBlock26.ts(17,18): error TS1005: ':' expected. classStaticBlock26.ts(20,9): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(20,14): error TS1109: Expression expected. -classStaticBlock26.ts(21,9): error TS18055: Cannot find label ''. +classStaticBlock26.ts(21,9): error TS18055: Label '' used before declaration classStaticBlock26.ts(21,15): error TS1003: Identifier expected. classStaticBlock26.ts(21,15): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(21,20): error TS1109: Expression expected. @@ -62,7 +62,7 @@ classStaticBlock26.ts(26,27): error TS1109: Expression expected. !!! error TS1109: Expression expected. break await; // illegal, 'await' cannot be used as a label ~~~~~ -!!! error TS18055: Cannot find label ''. +!!! error TS18055: Label '' used before declaration ~~~~~ !!! error TS1003: Identifier expected. ~~~~~ diff --git a/tests/baselines/reference/classStaticBlock8.errors.txt b/tests/baselines/reference/classStaticBlock8.errors.txt index 632cfdb94f750..2a89b91372fb6 100644 --- a/tests/baselines/reference/classStaticBlock8.errors.txt +++ b/tests/baselines/reference/classStaticBlock8.errors.txt @@ -1,5 +1,5 @@ -classStaticBlock8.ts(6,21): error TS18055: Cannot find label 'label'. -classStaticBlock8.ts(9,21): error TS18055: Cannot find label 'label'. +classStaticBlock8.ts(6,21): error TS18055: Label 'label' used before declaration +classStaticBlock8.ts(9,21): error TS18055: Label 'label' used before declaration classStaticBlock8.ts(12,21): error TS1107: Jump target cannot cross function boundary. classStaticBlock8.ts(15,21): error TS1107: Jump target cannot cross function boundary. @@ -12,12 +12,12 @@ classStaticBlock8.ts(15,21): error TS1107: Jump target cannot cross function bou if (v === 1) { break label; ~~~~~~~~~~~~ -!!! error TS18055: Cannot find label 'label'. +!!! error TS18055: Label 'label' used before declaration } if (v === 2) { continue label; ~~~~~~~~~~~~~~~ -!!! error TS18055: Cannot find label 'label'. +!!! error TS18055: Label 'label' used before declaration } if (v === 3) { break diff --git a/tests/baselines/reference/continueNotInIterationStatement4.errors.txt b/tests/baselines/reference/continueNotInIterationStatement4.errors.txt index 969dd957eeb6d..5fc9bd57eda5a 100644 --- a/tests/baselines/reference/continueNotInIterationStatement4.errors.txt +++ b/tests/baselines/reference/continueNotInIterationStatement4.errors.txt @@ -1,4 +1,4 @@ -continueNotInIterationStatement4.ts(4,5): error TS18055: Cannot find label 'TWO'. +continueNotInIterationStatement4.ts(4,5): error TS18055: Label 'TWO' used before declaration ==== continueNotInIterationStatement4.ts (1 errors) ==== @@ -7,7 +7,7 @@ continueNotInIterationStatement4.ts(4,5): error TS18055: Cannot find label 'TWO' var x = () => { continue TWO; ~~~~~~~~~~~~~ -!!! error TS18055: Cannot find label 'TWO'. +!!! error TS18055: Label 'TWO' used before declaration } } \ No newline at end of file diff --git a/tests/baselines/reference/continueTarget5.errors.txt b/tests/baselines/reference/continueTarget5.errors.txt index f2b0ac22b52fb..5fb068f18dc9e 100644 --- a/tests/baselines/reference/continueTarget5.errors.txt +++ b/tests/baselines/reference/continueTarget5.errors.txt @@ -1,4 +1,4 @@ -continueTarget5.ts(5,7): error TS18055: Cannot find label 'target'. +continueTarget5.ts(5,7): error TS18055: Label 'target' used before declaration ==== continueTarget5.ts (1 errors) ==== @@ -8,7 +8,7 @@ continueTarget5.ts(5,7): error TS18055: Cannot find label 'target'. while (true) { continue target; ~~~~~~~~~~~~~~~~ -!!! error TS18055: Cannot find label 'target'. +!!! error TS18055: Label 'target' used before declaration } } } \ No newline at end of file diff --git a/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt b/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt index 750579696434c..b2f0275f8a91b 100644 --- a/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt @@ -1,7 +1,7 @@ invalidDoWhileBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. invalidDoWhileBreakStatements.ts(8,4): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -invalidDoWhileBreakStatements.ts(14,9): error TS18055: Cannot find label 'TWO'. -invalidDoWhileBreakStatements.ts(21,9): error TS18055: Cannot find label 'THREE'. +invalidDoWhileBreakStatements.ts(14,9): error TS18055: Label 'TWO' used before declaration +invalidDoWhileBreakStatements.ts(21,9): error TS18055: Label 'THREE' used before declaration invalidDoWhileBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. invalidDoWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. @@ -26,7 +26,7 @@ invalidDoWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can on var x = () => { break TWO; ~~~~~~~~~~ -!!! error TS18055: Cannot find label 'TWO'. +!!! error TS18055: Label 'TWO' used before declaration } }while (true) @@ -35,7 +35,7 @@ invalidDoWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can on var fn = function () { break THREE; ~~~~~~~~~~~~ -!!! error TS18055: Cannot find label 'THREE'. +!!! error TS18055: Label 'THREE' used before declaration } }while (true) diff --git a/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt b/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt index 7098b4f38a3db..2a6c6bfc6df29 100644 --- a/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt @@ -1,7 +1,7 @@ invalidDoWhileContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. invalidDoWhileContinueStatements.ts(8,4): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -invalidDoWhileContinueStatements.ts(14,9): error TS18055: Cannot find label 'TWO'. -invalidDoWhileContinueStatements.ts(21,9): error TS18055: Cannot find label 'THREE'. +invalidDoWhileContinueStatements.ts(14,9): error TS18055: Label 'TWO' used before declaration +invalidDoWhileContinueStatements.ts(21,9): error TS18055: Label 'THREE' used before declaration invalidDoWhileContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. invalidDoWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. @@ -26,7 +26,7 @@ invalidDoWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement var x = () => { continue TWO; ~~~~~~~~~~~~~ -!!! error TS18055: Cannot find label 'TWO'. +!!! error TS18055: Label 'TWO' used before declaration } }while (true) @@ -35,7 +35,7 @@ invalidDoWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement var fn = function () { continue THREE; ~~~~~~~~~~~~~~~ -!!! error TS18055: Cannot find label 'THREE'. +!!! error TS18055: Label 'THREE' used before declaration } }while (true) diff --git a/tests/baselines/reference/invalidForBreakStatements.errors.txt b/tests/baselines/reference/invalidForBreakStatements.errors.txt index 799258e221895..1122496a794d7 100644 --- a/tests/baselines/reference/invalidForBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidForBreakStatements.errors.txt @@ -1,7 +1,7 @@ invalidForBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. invalidForBreakStatements.ts(8,9): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -invalidForBreakStatements.ts(14,9): error TS18055: Cannot find label 'TWO'. -invalidForBreakStatements.ts(21,9): error TS18055: Cannot find label 'THREE'. +invalidForBreakStatements.ts(14,9): error TS18055: Label 'TWO' used before declaration +invalidForBreakStatements.ts(21,9): error TS18055: Label 'THREE' used before declaration invalidForBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. invalidForBreakStatements.ts(36,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. @@ -26,7 +26,7 @@ invalidForBreakStatements.ts(36,5): error TS1116: A 'break' statement can only j var x = () => { break TWO; ~~~~~~~~~~ -!!! error TS18055: Cannot find label 'TWO'. +!!! error TS18055: Label 'TWO' used before declaration } } @@ -35,7 +35,7 @@ invalidForBreakStatements.ts(36,5): error TS1116: A 'break' statement can only j var fn = function () { break THREE; ~~~~~~~~~~~~ -!!! error TS18055: Cannot find label 'THREE'. +!!! error TS18055: Label 'THREE' used before declaration } } diff --git a/tests/baselines/reference/invalidForContinueStatements.errors.txt b/tests/baselines/reference/invalidForContinueStatements.errors.txt index 77f8e96cf1554..d483adf10e853 100644 --- a/tests/baselines/reference/invalidForContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidForContinueStatements.errors.txt @@ -1,7 +1,7 @@ invalidForContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. invalidForContinueStatements.ts(8,9): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -invalidForContinueStatements.ts(14,9): error TS18055: Cannot find label 'TWO'. -invalidForContinueStatements.ts(21,9): error TS18055: Cannot find label 'THREE'. +invalidForContinueStatements.ts(14,9): error TS18055: Label 'TWO' used before declaration +invalidForContinueStatements.ts(21,9): error TS18055: Label 'THREE' used before declaration invalidForContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. invalidForContinueStatements.ts(36,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. @@ -26,7 +26,7 @@ invalidForContinueStatements.ts(36,5): error TS1115: A 'continue' statement can var x = () => { continue TWO; ~~~~~~~~~~~~~ -!!! error TS18055: Cannot find label 'TWO'. +!!! error TS18055: Label 'TWO' used before declaration } } @@ -35,7 +35,7 @@ invalidForContinueStatements.ts(36,5): error TS1115: A 'continue' statement can var fn = function () { continue THREE; ~~~~~~~~~~~~~~~ -!!! error TS18055: Cannot find label 'THREE'. +!!! error TS18055: Label 'THREE' used before declaration } } diff --git a/tests/baselines/reference/invalidForInBreakStatements.errors.txt b/tests/baselines/reference/invalidForInBreakStatements.errors.txt index 46583e0f67139..133c5dc9351a9 100644 --- a/tests/baselines/reference/invalidForInBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidForInBreakStatements.errors.txt @@ -1,7 +1,7 @@ invalidForInBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. invalidForInBreakStatements.ts(8,19): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -invalidForInBreakStatements.ts(14,9): error TS18055: Cannot find label 'TWO'. -invalidForInBreakStatements.ts(21,9): error TS18055: Cannot find label 'THREE'. +invalidForInBreakStatements.ts(14,9): error TS18055: Label 'TWO' used before declaration +invalidForInBreakStatements.ts(21,9): error TS18055: Label 'THREE' used before declaration invalidForInBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. invalidForInBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. @@ -26,7 +26,7 @@ invalidForInBreakStatements.ts(37,5): error TS1116: A 'break' statement can only var fn = () => { break TWO; ~~~~~~~~~~ -!!! error TS18055: Cannot find label 'TWO'. +!!! error TS18055: Label 'TWO' used before declaration } } @@ -35,7 +35,7 @@ invalidForInBreakStatements.ts(37,5): error TS1116: A 'break' statement can only var fn = function () { break THREE; ~~~~~~~~~~~~ -!!! error TS18055: Cannot find label 'THREE'. +!!! error TS18055: Label 'THREE' used before declaration } } diff --git a/tests/baselines/reference/invalidForInContinueStatements.errors.txt b/tests/baselines/reference/invalidForInContinueStatements.errors.txt index 98a9c3f87626f..6cf4bfc1c1d91 100644 --- a/tests/baselines/reference/invalidForInContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidForInContinueStatements.errors.txt @@ -1,7 +1,7 @@ invalidForInContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. invalidForInContinueStatements.ts(8,19): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -invalidForInContinueStatements.ts(14,9): error TS18055: Cannot find label 'TWO'. -invalidForInContinueStatements.ts(21,9): error TS18055: Cannot find label 'THREE'. +invalidForInContinueStatements.ts(14,9): error TS18055: Label 'TWO' used before declaration +invalidForInContinueStatements.ts(21,9): error TS18055: Label 'THREE' used before declaration invalidForInContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. invalidForInContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. @@ -26,7 +26,7 @@ invalidForInContinueStatements.ts(37,5): error TS1115: A 'continue' statement ca var fn = () => { continue TWO; ~~~~~~~~~~~~~ -!!! error TS18055: Cannot find label 'TWO'. +!!! error TS18055: Label 'TWO' used before declaration } } @@ -35,7 +35,7 @@ invalidForInContinueStatements.ts(37,5): error TS1115: A 'continue' statement ca var fn = function () { continue THREE; ~~~~~~~~~~~~~~~ -!!! error TS18055: Cannot find label 'THREE'. +!!! error TS18055: Label 'THREE' used before declaration } } diff --git a/tests/baselines/reference/invalidWhileBreakStatements.errors.txt b/tests/baselines/reference/invalidWhileBreakStatements.errors.txt index f79fd675fcc7f..ad3ac34a465c8 100644 --- a/tests/baselines/reference/invalidWhileBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidWhileBreakStatements.errors.txt @@ -1,7 +1,7 @@ invalidWhileBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. invalidWhileBreakStatements.ts(8,14): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -invalidWhileBreakStatements.ts(14,9): error TS18055: Cannot find label 'TWO'. -invalidWhileBreakStatements.ts(21,9): error TS18055: Cannot find label 'THREE'. +invalidWhileBreakStatements.ts(14,9): error TS18055: Label 'TWO' used before declaration +invalidWhileBreakStatements.ts(21,9): error TS18055: Label 'THREE' used before declaration invalidWhileBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. invalidWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. @@ -26,7 +26,7 @@ invalidWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only var x = () => { break TWO; ~~~~~~~~~~ -!!! error TS18055: Cannot find label 'TWO'. +!!! error TS18055: Label 'TWO' used before declaration } } @@ -35,7 +35,7 @@ invalidWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only var fn = function () { break THREE; ~~~~~~~~~~~~ -!!! error TS18055: Cannot find label 'THREE'. +!!! error TS18055: Label 'THREE' used before declaration } } diff --git a/tests/baselines/reference/invalidWhileContinueStatements.errors.txt b/tests/baselines/reference/invalidWhileContinueStatements.errors.txt index 1ed166ec8643f..ad3493cfd67b0 100644 --- a/tests/baselines/reference/invalidWhileContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidWhileContinueStatements.errors.txt @@ -1,7 +1,7 @@ invalidWhileContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. invalidWhileContinueStatements.ts(8,14): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -invalidWhileContinueStatements.ts(14,9): error TS18055: Cannot find label 'TWO'. -invalidWhileContinueStatements.ts(21,9): error TS18055: Cannot find label 'THREE'. +invalidWhileContinueStatements.ts(14,9): error TS18055: Label 'TWO' used before declaration +invalidWhileContinueStatements.ts(21,9): error TS18055: Label 'THREE' used before declaration invalidWhileContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. invalidWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. @@ -26,7 +26,7 @@ invalidWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement ca var x = () => { continue TWO; ~~~~~~~~~~~~~ -!!! error TS18055: Cannot find label 'TWO'. +!!! error TS18055: Label 'TWO' used before declaration } } @@ -35,7 +35,7 @@ invalidWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement ca var fn = function () { continue THREE; ~~~~~~~~~~~~~~~ -!!! error TS18055: Cannot find label 'THREE'. +!!! error TS18055: Label 'THREE' used before declaration } } diff --git a/tests/baselines/reference/parser_breakTarget5.errors.txt b/tests/baselines/reference/parser_breakTarget5.errors.txt index d59480adc5c9f..bcebcb80ab27d 100644 --- a/tests/baselines/reference/parser_breakTarget5.errors.txt +++ b/tests/baselines/reference/parser_breakTarget5.errors.txt @@ -1,4 +1,4 @@ -parser_breakTarget5.ts(5,7): error TS18055: Cannot find label 'target'. +parser_breakTarget5.ts(5,7): error TS18055: Label 'target' used before declaration ==== parser_breakTarget5.ts (1 errors) ==== @@ -8,7 +8,7 @@ parser_breakTarget5.ts(5,7): error TS18055: Cannot find label 'target'. while (true) { break target; ~~~~~~~~~~~~~ -!!! error TS18055: Cannot find label 'target'. +!!! error TS18055: Label 'target' used before declaration } } } \ No newline at end of file diff --git a/tests/baselines/reference/parser_continueNotInIterationStatement4.errors.txt b/tests/baselines/reference/parser_continueNotInIterationStatement4.errors.txt index 87af53ddd8c56..abb454492471d 100644 --- a/tests/baselines/reference/parser_continueNotInIterationStatement4.errors.txt +++ b/tests/baselines/reference/parser_continueNotInIterationStatement4.errors.txt @@ -1,4 +1,4 @@ -parser_continueNotInIterationStatement4.ts(4,5): error TS18055: Cannot find label 'TWO'. +parser_continueNotInIterationStatement4.ts(4,5): error TS18055: Label 'TWO' used before declaration ==== parser_continueNotInIterationStatement4.ts (1 errors) ==== @@ -7,7 +7,7 @@ parser_continueNotInIterationStatement4.ts(4,5): error TS18055: Cannot find labe var x = () => { continue TWO; ~~~~~~~~~~~~~ -!!! error TS18055: Cannot find label 'TWO'. +!!! error TS18055: Label 'TWO' used before declaration } } \ No newline at end of file diff --git a/tests/baselines/reference/parser_continueTarget5.errors.txt b/tests/baselines/reference/parser_continueTarget5.errors.txt index 25439a10c2561..d7f1e543e61d4 100644 --- a/tests/baselines/reference/parser_continueTarget5.errors.txt +++ b/tests/baselines/reference/parser_continueTarget5.errors.txt @@ -1,4 +1,4 @@ -parser_continueTarget5.ts(5,7): error TS18055: Cannot find label 'target'. +parser_continueTarget5.ts(5,7): error TS18055: Label 'target' used before declaration ==== parser_continueTarget5.ts (1 errors) ==== @@ -8,7 +8,7 @@ parser_continueTarget5.ts(5,7): error TS18055: Cannot find label 'target'. while (true) { continue target; ~~~~~~~~~~~~~~~~ -!!! error TS18055: Cannot find label 'target'. +!!! error TS18055: Label 'target' used before declaration } } } \ No newline at end of file From 65898702df41e451f326c646ea4f465982d6f4fe Mon Sep 17 00:00:00 2001 From: Mvmo Date: Thu, 3 Aug 2023 19:46:42 +0200 Subject: [PATCH 6/9] Add test for label not found case --- src/compiler/checker.ts | 9 ++------- tests/baselines/reference/breakTarget7.errors.txt | 12 ++++++++++++ tests/baselines/reference/breakTarget7.js | 14 ++++++++++++++ tests/baselines/reference/breakTarget7.symbols | 10 ++++++++++ tests/baselines/reference/breakTarget7.types | 13 +++++++++++++ tests/cases/compiler/breakTarget7.ts | 5 +++++ 6 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 tests/baselines/reference/breakTarget7.errors.txt create mode 100644 tests/baselines/reference/breakTarget7.js create mode 100644 tests/baselines/reference/breakTarget7.symbols create mode 100644 tests/baselines/reference/breakTarget7.types create mode 100644 tests/cases/compiler/breakTarget7.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a5a0af77bde72..d137e8a1b4281 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -48431,16 +48431,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { break; } - let matchingLabelDeclaration = false; - forEachChild(functionOrClassLike.body, (childNode) => { - if (matchingLabelDeclaration) { - return; - } - + forEachChild(functionOrClassLike.body, childNode => { const labeledStatement = childNode as LabeledStatement; if (labeledStatement.kind === SyntaxKind.LabeledStatement && labeledStatement.label.escapedText === node.label!.escapedText) { diagnostic.relatedInformation = [createDiagnosticForNode(labeledStatement.label, Diagnostics.Label_defined_here, labeledStatement.label.escapedText.toString())]; - matchingLabelDeclaration = true; + return true; } }); diff --git a/tests/baselines/reference/breakTarget7.errors.txt b/tests/baselines/reference/breakTarget7.errors.txt new file mode 100644 index 0000000000000..b96f62f498601 --- /dev/null +++ b/tests/baselines/reference/breakTarget7.errors.txt @@ -0,0 +1,12 @@ +breakTarget7.ts(2,5): error TS18055: Label 'target' used before declaration + + +==== breakTarget7.ts (1 errors) ==== + function functionContainingBreak() { + break target; + ~~~~~~~~~~~~~ +!!! error TS18055: Label 'target' used before declaration +!!! related TS18056 breakTarget7.ts:3:5: Label defined here + target:; + } + \ No newline at end of file diff --git a/tests/baselines/reference/breakTarget7.js b/tests/baselines/reference/breakTarget7.js new file mode 100644 index 0000000000000..89d95dac1f4e5 --- /dev/null +++ b/tests/baselines/reference/breakTarget7.js @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/breakTarget7.ts] //// + +//// [breakTarget7.ts] +function functionContainingBreak() { + break target; + target:; +} + + +//// [breakTarget7.js] +function functionContainingBreak() { + break target; + target: ; +} diff --git a/tests/baselines/reference/breakTarget7.symbols b/tests/baselines/reference/breakTarget7.symbols new file mode 100644 index 0000000000000..5e8de2b1939d2 --- /dev/null +++ b/tests/baselines/reference/breakTarget7.symbols @@ -0,0 +1,10 @@ +//// [tests/cases/compiler/breakTarget7.ts] //// + +=== breakTarget7.ts === +function functionContainingBreak() { +>functionContainingBreak : Symbol(functionContainingBreak, Decl(breakTarget7.ts, 0, 0)) + + break target; + target:; +} + diff --git a/tests/baselines/reference/breakTarget7.types b/tests/baselines/reference/breakTarget7.types new file mode 100644 index 0000000000000..ef02a2be6de9a --- /dev/null +++ b/tests/baselines/reference/breakTarget7.types @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/breakTarget7.ts] //// + +=== breakTarget7.ts === +function functionContainingBreak() { +>functionContainingBreak : () => void + + break target; +>target : any + + target:; +>target : any +} + diff --git a/tests/cases/compiler/breakTarget7.ts b/tests/cases/compiler/breakTarget7.ts new file mode 100644 index 0000000000000..c9bd4edc31cdf --- /dev/null +++ b/tests/cases/compiler/breakTarget7.ts @@ -0,0 +1,5 @@ +// @allowUnusedLabels: true +function functionContainingBreak() { + break target; + target:; +} From 6194a65f88ed360100e6b2fe533088d5598a9c20 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 25 Jul 2024 10:14:59 -0700 Subject: [PATCH 7/9] Fix toString --- src/compiler/checker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9a8b45b0a5314..69667ce1556bf 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -51607,7 +51607,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { while (current) { if (isFunctionLikeOrClassStaticBlockDeclaration(current)) { if (node.label) { - const diagnostic = createDiagnosticForNode(node, Diagnostics.Label_0_used_before_declaration, node.label.escapedText.toString()); + const diagnostic = createDiagnosticForNode(node, Diagnostics.Label_0_used_before_declaration, unescapeLeadingUnderscores(node.label.escapedText)); const functionOrClassLike = current as FunctionLikeDeclaration | ClassStaticBlockDeclaration; if (!functionOrClassLike.body) { @@ -51617,7 +51617,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { forEachChild(functionOrClassLike.body, childNode => { const labeledStatement = childNode as LabeledStatement; if (labeledStatement.kind === SyntaxKind.LabeledStatement && labeledStatement.label.escapedText === node.label!.escapedText) { - diagnostic.relatedInformation = [createDiagnosticForNode(labeledStatement.label, Diagnostics.Label_defined_here, labeledStatement.label.escapedText.toString())]; + diagnostic.relatedInformation = [createDiagnosticForNode(labeledStatement.label, Diagnostics.Label_defined_here, unescapeLeadingUnderscores(labeledStatement.label.escapedText))]; return true; } }); From 206c10e563ed18560202547f0e632b1e457b6a2c Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 25 Jul 2024 10:49:22 -0700 Subject: [PATCH 8/9] Add missing dot --- src/compiler/diagnosticMessages.json | 2 +- tests/baselines/reference/breakTarget5.errors.txt | 4 ++-- tests/baselines/reference/breakTarget7.errors.txt | 4 ++-- .../classStaticBlock26(target=es2022).errors.txt | 4 ++-- .../classStaticBlock26(target=esnext).errors.txt | 4 ++-- tests/baselines/reference/classStaticBlock8.errors.txt | 8 ++++---- .../reference/continueNotInIterationStatement4.errors.txt | 4 ++-- tests/baselines/reference/continueTarget5.errors.txt | 4 ++-- .../reference/invalidDoWhileBreakStatements.errors.txt | 8 ++++---- .../reference/invalidDoWhileContinueStatements.errors.txt | 8 ++++---- .../reference/invalidForBreakStatements.errors.txt | 8 ++++---- .../reference/invalidForContinueStatements.errors.txt | 8 ++++---- .../reference/invalidForInBreakStatements.errors.txt | 8 ++++---- .../reference/invalidForInContinueStatements.errors.txt | 8 ++++---- .../reference/invalidWhileBreakStatements.errors.txt | 8 ++++---- .../reference/invalidWhileContinueStatements.errors.txt | 8 ++++---- tests/baselines/reference/parser_breakTarget5.errors.txt | 4 ++-- .../parser_continueNotInIterationStatement4.errors.txt | 4 ++-- .../baselines/reference/parser_continueTarget5.errors.txt | 4 ++-- 19 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9a5c99c6700eb..6828778bc3eb3 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -8354,7 +8354,7 @@ "category": "Error", "code": 18057 }, - "Label '{0}' used before declaration": { + "Label '{0}' used before declaration.": { "category": "Error", "code": 18058 }, diff --git a/tests/baselines/reference/breakTarget5.errors.txt b/tests/baselines/reference/breakTarget5.errors.txt index 37996486460fa..a7a7e8ccc88f4 100644 --- a/tests/baselines/reference/breakTarget5.errors.txt +++ b/tests/baselines/reference/breakTarget5.errors.txt @@ -1,4 +1,4 @@ -breakTarget5.ts(5,7): error TS18058: Label 'target' used before declaration +breakTarget5.ts(5,7): error TS18058: Label 'target' used before declaration. ==== breakTarget5.ts (1 errors) ==== @@ -8,7 +8,7 @@ breakTarget5.ts(5,7): error TS18058: Label 'target' used before declaration while (true) { break target; ~~~~~~~~~~~~~ -!!! error TS18058: Label 'target' used before declaration +!!! error TS18058: Label 'target' used before declaration. } } } \ No newline at end of file diff --git a/tests/baselines/reference/breakTarget7.errors.txt b/tests/baselines/reference/breakTarget7.errors.txt index 028695d4ce8e8..07eebeb3c5982 100644 --- a/tests/baselines/reference/breakTarget7.errors.txt +++ b/tests/baselines/reference/breakTarget7.errors.txt @@ -1,11 +1,11 @@ -breakTarget7.ts(2,5): error TS18058: Label 'target' used before declaration +breakTarget7.ts(2,5): error TS18058: Label 'target' used before declaration. ==== breakTarget7.ts (1 errors) ==== function functionContainingBreak() { break target; ~~~~~~~~~~~~~ -!!! error TS18058: Label 'target' used before declaration +!!! error TS18058: Label 'target' used before declaration. !!! related TS18059 breakTarget7.ts:3:5: Label defined here target:; } diff --git a/tests/baselines/reference/classStaticBlock26(target=es2022).errors.txt b/tests/baselines/reference/classStaticBlock26(target=es2022).errors.txt index 2b76be3ea5aa6..a9cc81be36d41 100644 --- a/tests/baselines/reference/classStaticBlock26(target=es2022).errors.txt +++ b/tests/baselines/reference/classStaticBlock26(target=es2022).errors.txt @@ -8,7 +8,7 @@ classStaticBlock26.ts(13,19): error TS1109: Expression expected. classStaticBlock26.ts(17,18): error TS1005: ':' expected. classStaticBlock26.ts(20,9): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(20,14): error TS1109: Expression expected. -classStaticBlock26.ts(21,9): error TS18058: Label '' used before declaration +classStaticBlock26.ts(21,9): error TS18058: Label '' used before declaration. classStaticBlock26.ts(21,15): error TS1003: Identifier expected. classStaticBlock26.ts(21,15): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(21,20): error TS1109: Expression expected. @@ -62,7 +62,7 @@ classStaticBlock26.ts(26,27): error TS1109: Expression expected. !!! error TS1109: Expression expected. break await; // illegal, 'await' cannot be used as a label ~~~~~ -!!! error TS18058: Label '' used before declaration +!!! error TS18058: Label '' used before declaration. ~~~~~ !!! error TS1003: Identifier expected. ~~~~~ diff --git a/tests/baselines/reference/classStaticBlock26(target=esnext).errors.txt b/tests/baselines/reference/classStaticBlock26(target=esnext).errors.txt index 2b76be3ea5aa6..a9cc81be36d41 100644 --- a/tests/baselines/reference/classStaticBlock26(target=esnext).errors.txt +++ b/tests/baselines/reference/classStaticBlock26(target=esnext).errors.txt @@ -8,7 +8,7 @@ classStaticBlock26.ts(13,19): error TS1109: Expression expected. classStaticBlock26.ts(17,18): error TS1005: ':' expected. classStaticBlock26.ts(20,9): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(20,14): error TS1109: Expression expected. -classStaticBlock26.ts(21,9): error TS18058: Label '' used before declaration +classStaticBlock26.ts(21,9): error TS18058: Label '' used before declaration. classStaticBlock26.ts(21,15): error TS1003: Identifier expected. classStaticBlock26.ts(21,15): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(21,20): error TS1109: Expression expected. @@ -62,7 +62,7 @@ classStaticBlock26.ts(26,27): error TS1109: Expression expected. !!! error TS1109: Expression expected. break await; // illegal, 'await' cannot be used as a label ~~~~~ -!!! error TS18058: Label '' used before declaration +!!! error TS18058: Label '' used before declaration. ~~~~~ !!! error TS1003: Identifier expected. ~~~~~ diff --git a/tests/baselines/reference/classStaticBlock8.errors.txt b/tests/baselines/reference/classStaticBlock8.errors.txt index 051f91dbf191e..79ea2c524be0a 100644 --- a/tests/baselines/reference/classStaticBlock8.errors.txt +++ b/tests/baselines/reference/classStaticBlock8.errors.txt @@ -1,5 +1,5 @@ -classStaticBlock8.ts(6,21): error TS18058: Label 'label' used before declaration -classStaticBlock8.ts(9,21): error TS18058: Label 'label' used before declaration +classStaticBlock8.ts(6,21): error TS18058: Label 'label' used before declaration. +classStaticBlock8.ts(9,21): error TS18058: Label 'label' used before declaration. classStaticBlock8.ts(12,21): error TS1107: Jump target cannot cross function boundary. classStaticBlock8.ts(15,21): error TS1107: Jump target cannot cross function boundary. @@ -12,12 +12,12 @@ classStaticBlock8.ts(15,21): error TS1107: Jump target cannot cross function bou if (v === 1) { break label; ~~~~~~~~~~~~ -!!! error TS18058: Label 'label' used before declaration +!!! error TS18058: Label 'label' used before declaration. } if (v === 2) { continue label; ~~~~~~~~~~~~~~~ -!!! error TS18058: Label 'label' used before declaration +!!! error TS18058: Label 'label' used before declaration. } if (v === 3) { break diff --git a/tests/baselines/reference/continueNotInIterationStatement4.errors.txt b/tests/baselines/reference/continueNotInIterationStatement4.errors.txt index 076468850221c..522644441ba9f 100644 --- a/tests/baselines/reference/continueNotInIterationStatement4.errors.txt +++ b/tests/baselines/reference/continueNotInIterationStatement4.errors.txt @@ -1,4 +1,4 @@ -continueNotInIterationStatement4.ts(4,5): error TS18058: Label 'TWO' used before declaration +continueNotInIterationStatement4.ts(4,5): error TS18058: Label 'TWO' used before declaration. ==== continueNotInIterationStatement4.ts (1 errors) ==== @@ -7,7 +7,7 @@ continueNotInIterationStatement4.ts(4,5): error TS18058: Label 'TWO' used before var x = () => { continue TWO; ~~~~~~~~~~~~~ -!!! error TS18058: Label 'TWO' used before declaration +!!! error TS18058: Label 'TWO' used before declaration. } } \ No newline at end of file diff --git a/tests/baselines/reference/continueTarget5.errors.txt b/tests/baselines/reference/continueTarget5.errors.txt index 34199228f8e2a..edea04481dca6 100644 --- a/tests/baselines/reference/continueTarget5.errors.txt +++ b/tests/baselines/reference/continueTarget5.errors.txt @@ -1,4 +1,4 @@ -continueTarget5.ts(5,7): error TS18058: Label 'target' used before declaration +continueTarget5.ts(5,7): error TS18058: Label 'target' used before declaration. ==== continueTarget5.ts (1 errors) ==== @@ -8,7 +8,7 @@ continueTarget5.ts(5,7): error TS18058: Label 'target' used before declaration while (true) { continue target; ~~~~~~~~~~~~~~~~ -!!! error TS18058: Label 'target' used before declaration +!!! error TS18058: Label 'target' used before declaration. } } } \ No newline at end of file diff --git a/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt b/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt index c3122c7aee4b4..b064eeb5f1a52 100644 --- a/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt @@ -1,7 +1,7 @@ invalidDoWhileBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. invalidDoWhileBreakStatements.ts(8,4): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -invalidDoWhileBreakStatements.ts(14,9): error TS18058: Label 'TWO' used before declaration -invalidDoWhileBreakStatements.ts(21,9): error TS18058: Label 'THREE' used before declaration +invalidDoWhileBreakStatements.ts(14,9): error TS18058: Label 'TWO' used before declaration. +invalidDoWhileBreakStatements.ts(21,9): error TS18058: Label 'THREE' used before declaration. invalidDoWhileBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. invalidDoWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. @@ -26,7 +26,7 @@ invalidDoWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can on var x = () => { break TWO; ~~~~~~~~~~ -!!! error TS18058: Label 'TWO' used before declaration +!!! error TS18058: Label 'TWO' used before declaration. } }while (true) @@ -35,7 +35,7 @@ invalidDoWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can on var fn = function () { break THREE; ~~~~~~~~~~~~ -!!! error TS18058: Label 'THREE' used before declaration +!!! error TS18058: Label 'THREE' used before declaration. } }while (true) diff --git a/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt b/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt index a78f7c16bb050..f7eca313f7f4f 100644 --- a/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt @@ -1,7 +1,7 @@ invalidDoWhileContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. invalidDoWhileContinueStatements.ts(8,4): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -invalidDoWhileContinueStatements.ts(14,9): error TS18058: Label 'TWO' used before declaration -invalidDoWhileContinueStatements.ts(21,9): error TS18058: Label 'THREE' used before declaration +invalidDoWhileContinueStatements.ts(14,9): error TS18058: Label 'TWO' used before declaration. +invalidDoWhileContinueStatements.ts(21,9): error TS18058: Label 'THREE' used before declaration. invalidDoWhileContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. invalidDoWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. @@ -26,7 +26,7 @@ invalidDoWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement var x = () => { continue TWO; ~~~~~~~~~~~~~ -!!! error TS18058: Label 'TWO' used before declaration +!!! error TS18058: Label 'TWO' used before declaration. } }while (true) @@ -35,7 +35,7 @@ invalidDoWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement var fn = function () { continue THREE; ~~~~~~~~~~~~~~~ -!!! error TS18058: Label 'THREE' used before declaration +!!! error TS18058: Label 'THREE' used before declaration. } }while (true) diff --git a/tests/baselines/reference/invalidForBreakStatements.errors.txt b/tests/baselines/reference/invalidForBreakStatements.errors.txt index c58fec997b87c..ec9d093162397 100644 --- a/tests/baselines/reference/invalidForBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidForBreakStatements.errors.txt @@ -1,7 +1,7 @@ invalidForBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. invalidForBreakStatements.ts(8,9): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -invalidForBreakStatements.ts(14,9): error TS18058: Label 'TWO' used before declaration -invalidForBreakStatements.ts(21,9): error TS18058: Label 'THREE' used before declaration +invalidForBreakStatements.ts(14,9): error TS18058: Label 'TWO' used before declaration. +invalidForBreakStatements.ts(21,9): error TS18058: Label 'THREE' used before declaration. invalidForBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. invalidForBreakStatements.ts(36,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. @@ -26,7 +26,7 @@ invalidForBreakStatements.ts(36,5): error TS1116: A 'break' statement can only j var x = () => { break TWO; ~~~~~~~~~~ -!!! error TS18058: Label 'TWO' used before declaration +!!! error TS18058: Label 'TWO' used before declaration. } } @@ -35,7 +35,7 @@ invalidForBreakStatements.ts(36,5): error TS1116: A 'break' statement can only j var fn = function () { break THREE; ~~~~~~~~~~~~ -!!! error TS18058: Label 'THREE' used before declaration +!!! error TS18058: Label 'THREE' used before declaration. } } diff --git a/tests/baselines/reference/invalidForContinueStatements.errors.txt b/tests/baselines/reference/invalidForContinueStatements.errors.txt index dfbe68cfc26e1..2f073e7bc485a 100644 --- a/tests/baselines/reference/invalidForContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidForContinueStatements.errors.txt @@ -1,7 +1,7 @@ invalidForContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. invalidForContinueStatements.ts(8,9): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -invalidForContinueStatements.ts(14,9): error TS18058: Label 'TWO' used before declaration -invalidForContinueStatements.ts(21,9): error TS18058: Label 'THREE' used before declaration +invalidForContinueStatements.ts(14,9): error TS18058: Label 'TWO' used before declaration. +invalidForContinueStatements.ts(21,9): error TS18058: Label 'THREE' used before declaration. invalidForContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. invalidForContinueStatements.ts(36,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. @@ -26,7 +26,7 @@ invalidForContinueStatements.ts(36,5): error TS1115: A 'continue' statement can var x = () => { continue TWO; ~~~~~~~~~~~~~ -!!! error TS18058: Label 'TWO' used before declaration +!!! error TS18058: Label 'TWO' used before declaration. } } @@ -35,7 +35,7 @@ invalidForContinueStatements.ts(36,5): error TS1115: A 'continue' statement can var fn = function () { continue THREE; ~~~~~~~~~~~~~~~ -!!! error TS18058: Label 'THREE' used before declaration +!!! error TS18058: Label 'THREE' used before declaration. } } diff --git a/tests/baselines/reference/invalidForInBreakStatements.errors.txt b/tests/baselines/reference/invalidForInBreakStatements.errors.txt index 2d77834eed593..0bc8acfcce2f3 100644 --- a/tests/baselines/reference/invalidForInBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidForInBreakStatements.errors.txt @@ -1,7 +1,7 @@ invalidForInBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. invalidForInBreakStatements.ts(8,19): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -invalidForInBreakStatements.ts(14,9): error TS18058: Label 'TWO' used before declaration -invalidForInBreakStatements.ts(21,9): error TS18058: Label 'THREE' used before declaration +invalidForInBreakStatements.ts(14,9): error TS18058: Label 'TWO' used before declaration. +invalidForInBreakStatements.ts(21,9): error TS18058: Label 'THREE' used before declaration. invalidForInBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. invalidForInBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. @@ -26,7 +26,7 @@ invalidForInBreakStatements.ts(37,5): error TS1116: A 'break' statement can only var fn = () => { break TWO; ~~~~~~~~~~ -!!! error TS18058: Label 'TWO' used before declaration +!!! error TS18058: Label 'TWO' used before declaration. } } @@ -35,7 +35,7 @@ invalidForInBreakStatements.ts(37,5): error TS1116: A 'break' statement can only var fn = function () { break THREE; ~~~~~~~~~~~~ -!!! error TS18058: Label 'THREE' used before declaration +!!! error TS18058: Label 'THREE' used before declaration. } } diff --git a/tests/baselines/reference/invalidForInContinueStatements.errors.txt b/tests/baselines/reference/invalidForInContinueStatements.errors.txt index d6fd35b6dcd90..8975b2b02b019 100644 --- a/tests/baselines/reference/invalidForInContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidForInContinueStatements.errors.txt @@ -1,7 +1,7 @@ invalidForInContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. invalidForInContinueStatements.ts(8,19): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -invalidForInContinueStatements.ts(14,9): error TS18058: Label 'TWO' used before declaration -invalidForInContinueStatements.ts(21,9): error TS18058: Label 'THREE' used before declaration +invalidForInContinueStatements.ts(14,9): error TS18058: Label 'TWO' used before declaration. +invalidForInContinueStatements.ts(21,9): error TS18058: Label 'THREE' used before declaration. invalidForInContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. invalidForInContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. @@ -26,7 +26,7 @@ invalidForInContinueStatements.ts(37,5): error TS1115: A 'continue' statement ca var fn = () => { continue TWO; ~~~~~~~~~~~~~ -!!! error TS18058: Label 'TWO' used before declaration +!!! error TS18058: Label 'TWO' used before declaration. } } @@ -35,7 +35,7 @@ invalidForInContinueStatements.ts(37,5): error TS1115: A 'continue' statement ca var fn = function () { continue THREE; ~~~~~~~~~~~~~~~ -!!! error TS18058: Label 'THREE' used before declaration +!!! error TS18058: Label 'THREE' used before declaration. } } diff --git a/tests/baselines/reference/invalidWhileBreakStatements.errors.txt b/tests/baselines/reference/invalidWhileBreakStatements.errors.txt index bf0e5ae23b2e7..02fe3dba680e2 100644 --- a/tests/baselines/reference/invalidWhileBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidWhileBreakStatements.errors.txt @@ -1,7 +1,7 @@ invalidWhileBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. invalidWhileBreakStatements.ts(8,14): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -invalidWhileBreakStatements.ts(14,9): error TS18058: Label 'TWO' used before declaration -invalidWhileBreakStatements.ts(21,9): error TS18058: Label 'THREE' used before declaration +invalidWhileBreakStatements.ts(14,9): error TS18058: Label 'TWO' used before declaration. +invalidWhileBreakStatements.ts(21,9): error TS18058: Label 'THREE' used before declaration. invalidWhileBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. invalidWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. @@ -26,7 +26,7 @@ invalidWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only var x = () => { break TWO; ~~~~~~~~~~ -!!! error TS18058: Label 'TWO' used before declaration +!!! error TS18058: Label 'TWO' used before declaration. } } @@ -35,7 +35,7 @@ invalidWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only var fn = function () { break THREE; ~~~~~~~~~~~~ -!!! error TS18058: Label 'THREE' used before declaration +!!! error TS18058: Label 'THREE' used before declaration. } } diff --git a/tests/baselines/reference/invalidWhileContinueStatements.errors.txt b/tests/baselines/reference/invalidWhileContinueStatements.errors.txt index a6e871af212b4..cbbae22a7ae99 100644 --- a/tests/baselines/reference/invalidWhileContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidWhileContinueStatements.errors.txt @@ -1,7 +1,7 @@ invalidWhileContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. invalidWhileContinueStatements.ts(8,14): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -invalidWhileContinueStatements.ts(14,9): error TS18058: Label 'TWO' used before declaration -invalidWhileContinueStatements.ts(21,9): error TS18058: Label 'THREE' used before declaration +invalidWhileContinueStatements.ts(14,9): error TS18058: Label 'TWO' used before declaration. +invalidWhileContinueStatements.ts(21,9): error TS18058: Label 'THREE' used before declaration. invalidWhileContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. invalidWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. @@ -26,7 +26,7 @@ invalidWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement ca var x = () => { continue TWO; ~~~~~~~~~~~~~ -!!! error TS18058: Label 'TWO' used before declaration +!!! error TS18058: Label 'TWO' used before declaration. } } @@ -35,7 +35,7 @@ invalidWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement ca var fn = function () { continue THREE; ~~~~~~~~~~~~~~~ -!!! error TS18058: Label 'THREE' used before declaration +!!! error TS18058: Label 'THREE' used before declaration. } } diff --git a/tests/baselines/reference/parser_breakTarget5.errors.txt b/tests/baselines/reference/parser_breakTarget5.errors.txt index 93fb72ebb043e..c3c5ee9dc9708 100644 --- a/tests/baselines/reference/parser_breakTarget5.errors.txt +++ b/tests/baselines/reference/parser_breakTarget5.errors.txt @@ -1,4 +1,4 @@ -parser_breakTarget5.ts(5,7): error TS18058: Label 'target' used before declaration +parser_breakTarget5.ts(5,7): error TS18058: Label 'target' used before declaration. ==== parser_breakTarget5.ts (1 errors) ==== @@ -8,7 +8,7 @@ parser_breakTarget5.ts(5,7): error TS18058: Label 'target' used before declarati while (true) { break target; ~~~~~~~~~~~~~ -!!! error TS18058: Label 'target' used before declaration +!!! error TS18058: Label 'target' used before declaration. } } } \ No newline at end of file diff --git a/tests/baselines/reference/parser_continueNotInIterationStatement4.errors.txt b/tests/baselines/reference/parser_continueNotInIterationStatement4.errors.txt index 25f9c1901946f..87330ffab16bc 100644 --- a/tests/baselines/reference/parser_continueNotInIterationStatement4.errors.txt +++ b/tests/baselines/reference/parser_continueNotInIterationStatement4.errors.txt @@ -1,4 +1,4 @@ -parser_continueNotInIterationStatement4.ts(4,5): error TS18058: Label 'TWO' used before declaration +parser_continueNotInIterationStatement4.ts(4,5): error TS18058: Label 'TWO' used before declaration. ==== parser_continueNotInIterationStatement4.ts (1 errors) ==== @@ -7,7 +7,7 @@ parser_continueNotInIterationStatement4.ts(4,5): error TS18058: Label 'TWO' used var x = () => { continue TWO; ~~~~~~~~~~~~~ -!!! error TS18058: Label 'TWO' used before declaration +!!! error TS18058: Label 'TWO' used before declaration. } } \ No newline at end of file diff --git a/tests/baselines/reference/parser_continueTarget5.errors.txt b/tests/baselines/reference/parser_continueTarget5.errors.txt index 20699118dddd3..517479bd123a6 100644 --- a/tests/baselines/reference/parser_continueTarget5.errors.txt +++ b/tests/baselines/reference/parser_continueTarget5.errors.txt @@ -1,4 +1,4 @@ -parser_continueTarget5.ts(5,7): error TS18058: Label 'target' used before declaration +parser_continueTarget5.ts(5,7): error TS18058: Label 'target' used before declaration. ==== parser_continueTarget5.ts (1 errors) ==== @@ -8,7 +8,7 @@ parser_continueTarget5.ts(5,7): error TS18058: Label 'target' used before declar while (true) { continue target; ~~~~~~~~~~~~~~~~ -!!! error TS18058: Label 'target' used before declaration +!!! error TS18058: Label 'target' used before declaration. } } } \ No newline at end of file From e61a99d125676be12a764be2ae752be1c44399db Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 25 Jul 2024 10:55:58 -0700 Subject: [PATCH 9/9] Restructure to avoid incorrect errors --- src/compiler/checker.ts | 25 +++++++++---------- .../reference/breakTarget5.errors.txt | 4 +-- ...assStaticBlock26(target=es2022).errors.txt | 5 +--- ...assStaticBlock26(target=esnext).errors.txt | 5 +--- .../reference/classStaticBlock8.errors.txt | 8 +++--- ...ontinueNotInIterationStatement4.errors.txt | 4 +-- .../reference/continueTarget5.errors.txt | 4 +-- .../invalidDoWhileBreakStatements.errors.txt | 8 +++--- ...nvalidDoWhileContinueStatements.errors.txt | 8 +++--- .../invalidForBreakStatements.errors.txt | 8 +++--- .../invalidForContinueStatements.errors.txt | 8 +++--- .../invalidForInBreakStatements.errors.txt | 8 +++--- .../invalidForInContinueStatements.errors.txt | 8 +++--- .../invalidWhileBreakStatements.errors.txt | 8 +++--- .../invalidWhileContinueStatements.errors.txt | 8 +++--- .../reference/parser_breakTarget5.errors.txt | 4 +-- ...ontinueNotInIterationStatement4.errors.txt | 4 +-- .../parser_continueTarget5.errors.txt | 4 +-- .../reference/plainJSBinderErrors.errors.txt | 5 +++- .../reference/plainJSGrammarErrors.errors.txt | 8 +++++- 20 files changed, 73 insertions(+), 71 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 69667ce1556bf..a483eae180310 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -51607,23 +51607,22 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { while (current) { if (isFunctionLikeOrClassStaticBlockDeclaration(current)) { if (node.label) { - const diagnostic = createDiagnosticForNode(node, Diagnostics.Label_0_used_before_declaration, unescapeLeadingUnderscores(node.label.escapedText)); - const functionOrClassLike = current as FunctionLikeDeclaration | ClassStaticBlockDeclaration; - if (!functionOrClassLike.body) { - break; - } + if (functionOrClassLike.body) { + const relatedInfo = forEachChild(functionOrClassLike.body, childNode => { + const labeledStatement = childNode as LabeledStatement; + if (labeledStatement.kind === SyntaxKind.LabeledStatement && labeledStatement.label.escapedText === node.label!.escapedText) { + return createDiagnosticForNode(labeledStatement.label, Diagnostics.Label_defined_here, unescapeLeadingUnderscores(labeledStatement.label.escapedText)); + } + }); - forEachChild(functionOrClassLike.body, childNode => { - const labeledStatement = childNode as LabeledStatement; - if (labeledStatement.kind === SyntaxKind.LabeledStatement && labeledStatement.label.escapedText === node.label!.escapedText) { - diagnostic.relatedInformation = [createDiagnosticForNode(labeledStatement.label, Diagnostics.Label_defined_here, unescapeLeadingUnderscores(labeledStatement.label.escapedText))]; + if (relatedInfo) { + const diagnostic = createDiagnosticForNode(node, Diagnostics.Label_0_used_before_declaration, unescapeLeadingUnderscores(node.label.escapedText)); + diagnostic.relatedInformation = [relatedInfo]; + diagnostics.add(diagnostic); return true; } - }); - - diagnostics.add(diagnostic); - return true; + } } return grammarErrorOnNode(node, Diagnostics.Jump_target_cannot_cross_function_boundary); diff --git a/tests/baselines/reference/breakTarget5.errors.txt b/tests/baselines/reference/breakTarget5.errors.txt index a7a7e8ccc88f4..b842116ccca78 100644 --- a/tests/baselines/reference/breakTarget5.errors.txt +++ b/tests/baselines/reference/breakTarget5.errors.txt @@ -1,4 +1,4 @@ -breakTarget5.ts(5,7): error TS18058: Label 'target' used before declaration. +breakTarget5.ts(5,7): error TS1107: Jump target cannot cross function boundary. ==== breakTarget5.ts (1 errors) ==== @@ -8,7 +8,7 @@ breakTarget5.ts(5,7): error TS18058: Label 'target' used before declaration. while (true) { break target; ~~~~~~~~~~~~~ -!!! error TS18058: Label 'target' used before declaration. +!!! error TS1107: Jump target cannot cross function boundary. } } } \ No newline at end of file diff --git a/tests/baselines/reference/classStaticBlock26(target=es2022).errors.txt b/tests/baselines/reference/classStaticBlock26(target=es2022).errors.txt index a9cc81be36d41..108e2368dad7f 100644 --- a/tests/baselines/reference/classStaticBlock26(target=es2022).errors.txt +++ b/tests/baselines/reference/classStaticBlock26(target=es2022).errors.txt @@ -8,7 +8,6 @@ classStaticBlock26.ts(13,19): error TS1109: Expression expected. classStaticBlock26.ts(17,18): error TS1005: ':' expected. classStaticBlock26.ts(20,9): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(20,14): error TS1109: Expression expected. -classStaticBlock26.ts(21,9): error TS18058: Label '' used before declaration. classStaticBlock26.ts(21,15): error TS1003: Identifier expected. classStaticBlock26.ts(21,15): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(21,20): error TS1109: Expression expected. @@ -19,7 +18,7 @@ classStaticBlock26.ts(26,21): error TS18037: 'await' expression cannot be used i classStaticBlock26.ts(26,27): error TS1109: Expression expected. -==== classStaticBlock26.ts (19 errors) ==== +==== classStaticBlock26.ts (18 errors) ==== class C { static { await; // illegal @@ -61,8 +60,6 @@ classStaticBlock26.ts(26,27): error TS1109: Expression expected. ~ !!! error TS1109: Expression expected. break await; // illegal, 'await' cannot be used as a label - ~~~~~ -!!! error TS18058: Label '' used before declaration. ~~~~~ !!! error TS1003: Identifier expected. ~~~~~ diff --git a/tests/baselines/reference/classStaticBlock26(target=esnext).errors.txt b/tests/baselines/reference/classStaticBlock26(target=esnext).errors.txt index a9cc81be36d41..108e2368dad7f 100644 --- a/tests/baselines/reference/classStaticBlock26(target=esnext).errors.txt +++ b/tests/baselines/reference/classStaticBlock26(target=esnext).errors.txt @@ -8,7 +8,6 @@ classStaticBlock26.ts(13,19): error TS1109: Expression expected. classStaticBlock26.ts(17,18): error TS1005: ':' expected. classStaticBlock26.ts(20,9): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(20,14): error TS1109: Expression expected. -classStaticBlock26.ts(21,9): error TS18058: Label '' used before declaration. classStaticBlock26.ts(21,15): error TS1003: Identifier expected. classStaticBlock26.ts(21,15): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(21,20): error TS1109: Expression expected. @@ -19,7 +18,7 @@ classStaticBlock26.ts(26,21): error TS18037: 'await' expression cannot be used i classStaticBlock26.ts(26,27): error TS1109: Expression expected. -==== classStaticBlock26.ts (19 errors) ==== +==== classStaticBlock26.ts (18 errors) ==== class C { static { await; // illegal @@ -61,8 +60,6 @@ classStaticBlock26.ts(26,27): error TS1109: Expression expected. ~ !!! error TS1109: Expression expected. break await; // illegal, 'await' cannot be used as a label - ~~~~~ -!!! error TS18058: Label '' used before declaration. ~~~~~ !!! error TS1003: Identifier expected. ~~~~~ diff --git a/tests/baselines/reference/classStaticBlock8.errors.txt b/tests/baselines/reference/classStaticBlock8.errors.txt index 79ea2c524be0a..9dab71ffc8217 100644 --- a/tests/baselines/reference/classStaticBlock8.errors.txt +++ b/tests/baselines/reference/classStaticBlock8.errors.txt @@ -1,5 +1,5 @@ -classStaticBlock8.ts(6,21): error TS18058: Label 'label' used before declaration. -classStaticBlock8.ts(9,21): error TS18058: Label 'label' used before declaration. +classStaticBlock8.ts(6,21): error TS1107: Jump target cannot cross function boundary. +classStaticBlock8.ts(9,21): error TS1107: Jump target cannot cross function boundary. classStaticBlock8.ts(12,21): error TS1107: Jump target cannot cross function boundary. classStaticBlock8.ts(15,21): error TS1107: Jump target cannot cross function boundary. @@ -12,12 +12,12 @@ classStaticBlock8.ts(15,21): error TS1107: Jump target cannot cross function bou if (v === 1) { break label; ~~~~~~~~~~~~ -!!! error TS18058: Label 'label' used before declaration. +!!! error TS1107: Jump target cannot cross function boundary. } if (v === 2) { continue label; ~~~~~~~~~~~~~~~ -!!! error TS18058: Label 'label' used before declaration. +!!! error TS1107: Jump target cannot cross function boundary. } if (v === 3) { break diff --git a/tests/baselines/reference/continueNotInIterationStatement4.errors.txt b/tests/baselines/reference/continueNotInIterationStatement4.errors.txt index 522644441ba9f..a4e72cb4eb9c7 100644 --- a/tests/baselines/reference/continueNotInIterationStatement4.errors.txt +++ b/tests/baselines/reference/continueNotInIterationStatement4.errors.txt @@ -1,4 +1,4 @@ -continueNotInIterationStatement4.ts(4,5): error TS18058: Label 'TWO' used before declaration. +continueNotInIterationStatement4.ts(4,5): error TS1107: Jump target cannot cross function boundary. ==== continueNotInIterationStatement4.ts (1 errors) ==== @@ -7,7 +7,7 @@ continueNotInIterationStatement4.ts(4,5): error TS18058: Label 'TWO' used before var x = () => { continue TWO; ~~~~~~~~~~~~~ -!!! error TS18058: Label 'TWO' used before declaration. +!!! error TS1107: Jump target cannot cross function boundary. } } \ No newline at end of file diff --git a/tests/baselines/reference/continueTarget5.errors.txt b/tests/baselines/reference/continueTarget5.errors.txt index edea04481dca6..64e5270ac83f1 100644 --- a/tests/baselines/reference/continueTarget5.errors.txt +++ b/tests/baselines/reference/continueTarget5.errors.txt @@ -1,4 +1,4 @@ -continueTarget5.ts(5,7): error TS18058: Label 'target' used before declaration. +continueTarget5.ts(5,7): error TS1107: Jump target cannot cross function boundary. ==== continueTarget5.ts (1 errors) ==== @@ -8,7 +8,7 @@ continueTarget5.ts(5,7): error TS18058: Label 'target' used before declaration. while (true) { continue target; ~~~~~~~~~~~~~~~~ -!!! error TS18058: Label 'target' used before declaration. +!!! error TS1107: Jump target cannot cross function boundary. } } } \ No newline at end of file diff --git a/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt b/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt index b064eeb5f1a52..3e231d553b63b 100644 --- a/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt @@ -1,7 +1,7 @@ invalidDoWhileBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. invalidDoWhileBreakStatements.ts(8,4): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -invalidDoWhileBreakStatements.ts(14,9): error TS18058: Label 'TWO' used before declaration. -invalidDoWhileBreakStatements.ts(21,9): error TS18058: Label 'THREE' used before declaration. +invalidDoWhileBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. +invalidDoWhileBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. invalidDoWhileBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. invalidDoWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. @@ -26,7 +26,7 @@ invalidDoWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can on var x = () => { break TWO; ~~~~~~~~~~ -!!! error TS18058: Label 'TWO' used before declaration. +!!! error TS1107: Jump target cannot cross function boundary. } }while (true) @@ -35,7 +35,7 @@ invalidDoWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can on var fn = function () { break THREE; ~~~~~~~~~~~~ -!!! error TS18058: Label 'THREE' used before declaration. +!!! error TS1107: Jump target cannot cross function boundary. } }while (true) diff --git a/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt b/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt index f7eca313f7f4f..33a60d7f45fe5 100644 --- a/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt @@ -1,7 +1,7 @@ invalidDoWhileContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. invalidDoWhileContinueStatements.ts(8,4): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -invalidDoWhileContinueStatements.ts(14,9): error TS18058: Label 'TWO' used before declaration. -invalidDoWhileContinueStatements.ts(21,9): error TS18058: Label 'THREE' used before declaration. +invalidDoWhileContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. +invalidDoWhileContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. invalidDoWhileContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. invalidDoWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. @@ -26,7 +26,7 @@ invalidDoWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement var x = () => { continue TWO; ~~~~~~~~~~~~~ -!!! error TS18058: Label 'TWO' used before declaration. +!!! error TS1107: Jump target cannot cross function boundary. } }while (true) @@ -35,7 +35,7 @@ invalidDoWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement var fn = function () { continue THREE; ~~~~~~~~~~~~~~~ -!!! error TS18058: Label 'THREE' used before declaration. +!!! error TS1107: Jump target cannot cross function boundary. } }while (true) diff --git a/tests/baselines/reference/invalidForBreakStatements.errors.txt b/tests/baselines/reference/invalidForBreakStatements.errors.txt index ec9d093162397..099663ea32f24 100644 --- a/tests/baselines/reference/invalidForBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidForBreakStatements.errors.txt @@ -1,7 +1,7 @@ invalidForBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. invalidForBreakStatements.ts(8,9): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -invalidForBreakStatements.ts(14,9): error TS18058: Label 'TWO' used before declaration. -invalidForBreakStatements.ts(21,9): error TS18058: Label 'THREE' used before declaration. +invalidForBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. +invalidForBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. invalidForBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. invalidForBreakStatements.ts(36,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. @@ -26,7 +26,7 @@ invalidForBreakStatements.ts(36,5): error TS1116: A 'break' statement can only j var x = () => { break TWO; ~~~~~~~~~~ -!!! error TS18058: Label 'TWO' used before declaration. +!!! error TS1107: Jump target cannot cross function boundary. } } @@ -35,7 +35,7 @@ invalidForBreakStatements.ts(36,5): error TS1116: A 'break' statement can only j var fn = function () { break THREE; ~~~~~~~~~~~~ -!!! error TS18058: Label 'THREE' used before declaration. +!!! error TS1107: Jump target cannot cross function boundary. } } diff --git a/tests/baselines/reference/invalidForContinueStatements.errors.txt b/tests/baselines/reference/invalidForContinueStatements.errors.txt index 2f073e7bc485a..a13982e633c23 100644 --- a/tests/baselines/reference/invalidForContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidForContinueStatements.errors.txt @@ -1,7 +1,7 @@ invalidForContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. invalidForContinueStatements.ts(8,9): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -invalidForContinueStatements.ts(14,9): error TS18058: Label 'TWO' used before declaration. -invalidForContinueStatements.ts(21,9): error TS18058: Label 'THREE' used before declaration. +invalidForContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. +invalidForContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. invalidForContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. invalidForContinueStatements.ts(36,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. @@ -26,7 +26,7 @@ invalidForContinueStatements.ts(36,5): error TS1115: A 'continue' statement can var x = () => { continue TWO; ~~~~~~~~~~~~~ -!!! error TS18058: Label 'TWO' used before declaration. +!!! error TS1107: Jump target cannot cross function boundary. } } @@ -35,7 +35,7 @@ invalidForContinueStatements.ts(36,5): error TS1115: A 'continue' statement can var fn = function () { continue THREE; ~~~~~~~~~~~~~~~ -!!! error TS18058: Label 'THREE' used before declaration. +!!! error TS1107: Jump target cannot cross function boundary. } } diff --git a/tests/baselines/reference/invalidForInBreakStatements.errors.txt b/tests/baselines/reference/invalidForInBreakStatements.errors.txt index 0bc8acfcce2f3..373d9bf99df21 100644 --- a/tests/baselines/reference/invalidForInBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidForInBreakStatements.errors.txt @@ -1,7 +1,7 @@ invalidForInBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. invalidForInBreakStatements.ts(8,19): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -invalidForInBreakStatements.ts(14,9): error TS18058: Label 'TWO' used before declaration. -invalidForInBreakStatements.ts(21,9): error TS18058: Label 'THREE' used before declaration. +invalidForInBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. +invalidForInBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. invalidForInBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. invalidForInBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. @@ -26,7 +26,7 @@ invalidForInBreakStatements.ts(37,5): error TS1116: A 'break' statement can only var fn = () => { break TWO; ~~~~~~~~~~ -!!! error TS18058: Label 'TWO' used before declaration. +!!! error TS1107: Jump target cannot cross function boundary. } } @@ -35,7 +35,7 @@ invalidForInBreakStatements.ts(37,5): error TS1116: A 'break' statement can only var fn = function () { break THREE; ~~~~~~~~~~~~ -!!! error TS18058: Label 'THREE' used before declaration. +!!! error TS1107: Jump target cannot cross function boundary. } } diff --git a/tests/baselines/reference/invalidForInContinueStatements.errors.txt b/tests/baselines/reference/invalidForInContinueStatements.errors.txt index 8975b2b02b019..71e765d3fa114 100644 --- a/tests/baselines/reference/invalidForInContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidForInContinueStatements.errors.txt @@ -1,7 +1,7 @@ invalidForInContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. invalidForInContinueStatements.ts(8,19): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -invalidForInContinueStatements.ts(14,9): error TS18058: Label 'TWO' used before declaration. -invalidForInContinueStatements.ts(21,9): error TS18058: Label 'THREE' used before declaration. +invalidForInContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. +invalidForInContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. invalidForInContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. invalidForInContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. @@ -26,7 +26,7 @@ invalidForInContinueStatements.ts(37,5): error TS1115: A 'continue' statement ca var fn = () => { continue TWO; ~~~~~~~~~~~~~ -!!! error TS18058: Label 'TWO' used before declaration. +!!! error TS1107: Jump target cannot cross function boundary. } } @@ -35,7 +35,7 @@ invalidForInContinueStatements.ts(37,5): error TS1115: A 'continue' statement ca var fn = function () { continue THREE; ~~~~~~~~~~~~~~~ -!!! error TS18058: Label 'THREE' used before declaration. +!!! error TS1107: Jump target cannot cross function boundary. } } diff --git a/tests/baselines/reference/invalidWhileBreakStatements.errors.txt b/tests/baselines/reference/invalidWhileBreakStatements.errors.txt index 02fe3dba680e2..b93a32288b213 100644 --- a/tests/baselines/reference/invalidWhileBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidWhileBreakStatements.errors.txt @@ -1,7 +1,7 @@ invalidWhileBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. invalidWhileBreakStatements.ts(8,14): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -invalidWhileBreakStatements.ts(14,9): error TS18058: Label 'TWO' used before declaration. -invalidWhileBreakStatements.ts(21,9): error TS18058: Label 'THREE' used before declaration. +invalidWhileBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. +invalidWhileBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. invalidWhileBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. invalidWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. @@ -26,7 +26,7 @@ invalidWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only var x = () => { break TWO; ~~~~~~~~~~ -!!! error TS18058: Label 'TWO' used before declaration. +!!! error TS1107: Jump target cannot cross function boundary. } } @@ -35,7 +35,7 @@ invalidWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only var fn = function () { break THREE; ~~~~~~~~~~~~ -!!! error TS18058: Label 'THREE' used before declaration. +!!! error TS1107: Jump target cannot cross function boundary. } } diff --git a/tests/baselines/reference/invalidWhileContinueStatements.errors.txt b/tests/baselines/reference/invalidWhileContinueStatements.errors.txt index cbbae22a7ae99..e49c679e83f42 100644 --- a/tests/baselines/reference/invalidWhileContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidWhileContinueStatements.errors.txt @@ -1,7 +1,7 @@ invalidWhileContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. invalidWhileContinueStatements.ts(8,14): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -invalidWhileContinueStatements.ts(14,9): error TS18058: Label 'TWO' used before declaration. -invalidWhileContinueStatements.ts(21,9): error TS18058: Label 'THREE' used before declaration. +invalidWhileContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. +invalidWhileContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. invalidWhileContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. invalidWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. @@ -26,7 +26,7 @@ invalidWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement ca var x = () => { continue TWO; ~~~~~~~~~~~~~ -!!! error TS18058: Label 'TWO' used before declaration. +!!! error TS1107: Jump target cannot cross function boundary. } } @@ -35,7 +35,7 @@ invalidWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement ca var fn = function () { continue THREE; ~~~~~~~~~~~~~~~ -!!! error TS18058: Label 'THREE' used before declaration. +!!! error TS1107: Jump target cannot cross function boundary. } } diff --git a/tests/baselines/reference/parser_breakTarget5.errors.txt b/tests/baselines/reference/parser_breakTarget5.errors.txt index c3c5ee9dc9708..46eede4e845bc 100644 --- a/tests/baselines/reference/parser_breakTarget5.errors.txt +++ b/tests/baselines/reference/parser_breakTarget5.errors.txt @@ -1,4 +1,4 @@ -parser_breakTarget5.ts(5,7): error TS18058: Label 'target' used before declaration. +parser_breakTarget5.ts(5,7): error TS1107: Jump target cannot cross function boundary. ==== parser_breakTarget5.ts (1 errors) ==== @@ -8,7 +8,7 @@ parser_breakTarget5.ts(5,7): error TS18058: Label 'target' used before declarati while (true) { break target; ~~~~~~~~~~~~~ -!!! error TS18058: Label 'target' used before declaration. +!!! error TS1107: Jump target cannot cross function boundary. } } } \ No newline at end of file diff --git a/tests/baselines/reference/parser_continueNotInIterationStatement4.errors.txt b/tests/baselines/reference/parser_continueNotInIterationStatement4.errors.txt index 87330ffab16bc..fd4b252fbd3d1 100644 --- a/tests/baselines/reference/parser_continueNotInIterationStatement4.errors.txt +++ b/tests/baselines/reference/parser_continueNotInIterationStatement4.errors.txt @@ -1,4 +1,4 @@ -parser_continueNotInIterationStatement4.ts(4,5): error TS18058: Label 'TWO' used before declaration. +parser_continueNotInIterationStatement4.ts(4,5): error TS1107: Jump target cannot cross function boundary. ==== parser_continueNotInIterationStatement4.ts (1 errors) ==== @@ -7,7 +7,7 @@ parser_continueNotInIterationStatement4.ts(4,5): error TS18058: Label 'TWO' used var x = () => { continue TWO; ~~~~~~~~~~~~~ -!!! error TS18058: Label 'TWO' used before declaration. +!!! error TS1107: Jump target cannot cross function boundary. } } \ No newline at end of file diff --git a/tests/baselines/reference/parser_continueTarget5.errors.txt b/tests/baselines/reference/parser_continueTarget5.errors.txt index 517479bd123a6..1a80e2d9f968c 100644 --- a/tests/baselines/reference/parser_continueTarget5.errors.txt +++ b/tests/baselines/reference/parser_continueTarget5.errors.txt @@ -1,4 +1,4 @@ -parser_continueTarget5.ts(5,7): error TS18058: Label 'target' used before declaration. +parser_continueTarget5.ts(5,7): error TS1107: Jump target cannot cross function boundary. ==== parser_continueTarget5.ts (1 errors) ==== @@ -8,7 +8,7 @@ parser_continueTarget5.ts(5,7): error TS18058: Label 'target' used before declar while (true) { continue target; ~~~~~~~~~~~~~~~~ -!!! error TS18058: Label 'target' used before declaration. +!!! error TS1107: Jump target cannot cross function boundary. } } } \ No newline at end of file diff --git a/tests/baselines/reference/plainJSBinderErrors.errors.txt b/tests/baselines/reference/plainJSBinderErrors.errors.txt index f85e8202b609b..8eeeb92765ee6 100644 --- a/tests/baselines/reference/plainJSBinderErrors.errors.txt +++ b/tests/baselines/reference/plainJSBinderErrors.errors.txt @@ -12,11 +12,12 @@ plainJSBinderErrors.js(22,15): error TS1210: Code contained in a class is evalua plainJSBinderErrors.js(23,15): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. plainJSBinderErrors.js(27,9): error TS1101: 'with' statements are not allowed in strict mode. plainJSBinderErrors.js(33,13): error TS1344: 'A label is not allowed here. +plainJSBinderErrors.js(34,13): error TS1107: Jump target cannot cross function boundary. plainJSBinderErrors.js(39,7): error TS1215: Invalid use of 'eval'. Modules are automatically in strict mode. plainJSBinderErrors.js(40,7): error TS1215: Invalid use of 'arguments'. Modules are automatically in strict mode. -==== plainJSBinderErrors.js (16 errors) ==== +==== plainJSBinderErrors.js (17 errors) ==== export default 12 ~~~~~~~~~~~~~~~~~ !!! error TS2528: A module cannot have multiple default exports. @@ -81,6 +82,8 @@ plainJSBinderErrors.js(40,7): error TS1215: Invalid use of 'arguments'. Modules ~~~~~ !!! error TS1344: 'A label is not allowed here. break label + ~~~~~~~~~~~ +!!! error TS1107: Jump target cannot cross function boundary. } return x } diff --git a/tests/baselines/reference/plainJSGrammarErrors.errors.txt b/tests/baselines/reference/plainJSGrammarErrors.errors.txt index 1555172e558cb..b92bd5df1b8ba 100644 --- a/tests/baselines/reference/plainJSGrammarErrors.errors.txt +++ b/tests/baselines/reference/plainJSGrammarErrors.errors.txt @@ -88,7 +88,9 @@ plainJSGrammarErrors.js(154,5): error TS1113: A 'default' clause cannot appear m plainJSGrammarErrors.js(161,11): error TS2492: Cannot redeclare identifier 'e' in catch clause. plainJSGrammarErrors.js(167,12): error TS1197: Catch clause variable cannot have an initializer. plainJSGrammarErrors.js(170,5): error TS1114: Duplicate label 'label'. +plainJSGrammarErrors.js(179,13): error TS1107: Jump target cannot cross function boundary. plainJSGrammarErrors.js(187,13): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +plainJSGrammarErrors.js(191,5): error TS1107: Jump target cannot cross function boundary. plainJSGrammarErrors.js(194,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. plainJSGrammarErrors.js(195,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. plainJSGrammarErrors.js(197,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. @@ -100,7 +102,7 @@ plainJSGrammarErrors.js(204,30): message TS1450: Dynamic imports can only accept plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot be spread element. -==== plainJSGrammarErrors.js (100 errors) ==== +==== plainJSGrammarErrors.js (102 errors) ==== class C { // #private mistakes q = #unbound @@ -460,6 +462,8 @@ plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot outer: for(;;) { function test() { break outer + ~~~~~~~~~~~ +!!! error TS1107: Jump target cannot cross function boundary. } test() } @@ -474,6 +478,8 @@ plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot } function jumpToLabelOnly(x) { break jumpToLabelOnly + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1107: Jump target cannot cross function boundary. } for (;;) { break toplevel