Skip to content

fix(30408): improve error message for labels used before definition#63302

Closed
wdskuki wants to merge 1 commit intomicrosoft:mainfrom
wdskuki:fix-issue-30408-improve-error-message
Closed

fix(30408): improve error message for labels used before definition#63302
wdskuki wants to merge 1 commit intomicrosoft:mainfrom
wdskuki:fix-issue-30408-improve-error-message

Conversation

@wdskuki
Copy link

@wdskuki wdskuki commented Mar 26, 2026

Description

The error message 'Jump target cannot cross function boundary' was confusing because it didn't indicate which label was causing the issue. This change adds the label name to the error message when available.

Changes

  • Added new error message format: "Jump target '{0}' cannot cross function boundary."
  • Updated checker.ts to use the new message format with the label name

Before

Jump target cannot cross function boundary.

After

Jump target 'loopend' cannot cross function boundary.

Example

function foo() {
    for (let i = 0; i < 10; i++) {
        console.log(`${i}`);
        continue loopend;  // Error: Jump target 'loopend' cannot cross function boundary.
    }

    loopend:
    console.log('end of loop');
}

Fixes #30408

The error message 'Jump target cannot cross function boundary' was confusing
because it didn't indicate which label was causing the issue. This change
adds the label name to the error message when available.

Before: 'Jump target cannot cross function boundary.'
After:  'Jump target 'loopend' cannot cross function boundary.'

Fixes microsoft#30408
@jakebailey
Copy link
Member

Sorry, but we are not accepting PRs of this kind at this time. https://github.com/microsoft/TypeScript#:~:text=NOTE%3A%20Code%20changes%20in%20this%20repo%20are%20now%20limited%20to%20a%20small%20category%20of%20fixes%3A


With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies).

Next steps for PRs:

  • For crash bugfixes or language service improvements, PRs are currently accepted at the typescript-go repo
  • Changes to type system behavior should wait until after 7.0, at which point mainline TypeScript development will resume in this repository with the Go codebase
  • Library file updates (lib.d.ts etc) continue to live in this repo or the DOM Generator repo as appropriate

@jakebailey jakebailey closed this Mar 26, 2026
@github-project-automation github-project-automation bot moved this from Not started to Done in PR Backlog Mar 26, 2026
@jakebailey
Copy link
Member

(Also, this seems to be an LLM generated PR, and clearly did not have any tests run.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Confusing error message for labels used before definition

2 participants