Repository navigation
Confusing error message for labels used before definition #30408
Description
Activity
- changed the title
[-]Invalid "TS1007: Jump target cannot cross function boundary error" error in TS 3.3[/-][+]Confusing error message for labels used before definition[/+]on Mar 14, 2019 DanielRosenwasser commented
on Mar 14, 2019 MemberMore actionsDid you try adding3s to the version to see if the error gets better?Seems like a reasonable request.
Reacted by Josh Ghoulberg 👻- addedHelp WantedYou can do thisYou can do thisGood First IssueWell scoped, documented and has the green lightWell scoped, documented and has the green lightDomain: Error MessagesThe issue relates to error messagingThe issue relates to error messagingDomain: Related Error SpansSpecifying regions for error messages/diagnostics on multiple locations.Specifying regions for error messages/diagnostics on multiple locations.
on Mar 14, 2019 DanielRosenwasser commented
on Mar 14, 2019 MemberMore actionsHere's a better message for this specific case, where the containing function of the label reference is the same as that of the labeled statement:
A label cannot be referenced prior to its declared location.To find if it's applicable, walk up each scope until the first functionlike (
isFunctionLike) or classlike (isClassLike) declaration and look for LabelledStatements in that scope.We can also provide a related span. We already have a diagnostic for
{0} is declared here.paulvanbrenk commented
on Mar 14, 2019 ContributorAuthorMore actions?????? Get Outlook for Android<https://aka.ms/ghei36>…________________________________ From: Daniel Rosenwasser <notifications@github.com> Sent: Thursday, March 14, 2019 6:41:32 PM To: Microsoft/TypeScript Cc: Paul van Brenk; Author Subject: Re: [Microsoft/TypeScript] Confusing error message for labels used before definition (#30408) Here's a better message for this specific case. A label cannot be referenced prior to its declared location. We also should provide a related span. We already have a diagnostic for {0} is declared here. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub<#30408 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AFB5dwK9ovsiqwXTAzc2LlmDu5_corNoks5vWtAcgaJpZM4b1HbC>.DanielRosenwasser commented
on Mar 15, 2019 MemberMore actionsActually, we already have a better message for
breakorcontinueerror messages.paulvanbrenk commented
on Mar 15, 2019 ContributorAuthorMore actionsIn 3.4? Get Outlook for Android<https://aka.ms/ghei36>…________________________________ From: Daniel Rosenwasser <notifications@github.com> Sent: Thursday, March 14, 2019 8:13:58 PM To: Microsoft/TypeScript Cc: Paul van Brenk; Author Subject: Re: [Microsoft/TypeScript] Confusing error message for labels used before definition (#30408) Actually, we already have a better message for break or continue error messages. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub<#30408 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AFB5d5sWoEtjlpcsCEz1AA8hP80x1ghKks5vWuXGgaJpZM4b1HbC>.- addedSuggestionAn idea for TypeScriptAn idea for TypeScriptExperience EnhancementNoncontroversial enhancementsNoncontroversial enhancements
on Mar 15, 2019 Hey -- is this still something that should be implemented? Happy to make changes now if no one else is already
paulvanbrenk commented
on Mar 28, 2019 ContributorAuthorMore actionsYes, please. This is still an issue in @next
9 remaining items
I can take this on, I have a fix for it. Please assign me.
- added a commit that references this issue
on Dec 24, 2025 - added a commit that references this issue
on Mar 26, 2026 - added a commit that references this issue
on Apr 6, 2026 - removedDomain: Related Error SpansSpecifying regions for error messages/diagnostics on multiple locations.Specifying regions for error messages/diagnostics on multiple locations.
on Apr 6, 2026 I encountered a similar issue.
setTimeout(() => { outerLoop: for(let i = 0; i < 3; i++) { break outerloop; // typo, "l" should be uppercase } });
In this case the label does not exist, but I still get the error "TS1107: Jump target cannot cross function boundary."
The problem still exists in version
7.0.0-dev.20260415.1(withtsgo).- added 3 commits that reference this issue
on Apr 18, 2026 I'd like to take this one — I'll follow up with a PR. (claiming via Stella (@LeonxLJX))
Hi! I'd like to improve the 'label used before definition' error message. Plan: reproduce, refine the message, add tests. May I be assigned?
Hey, i would like to work on this. Can i be assigned this issue?
RyanCavanaugh commented
on Sep 28, 2026 MemberMore actionsOpening another PR for this issue without acknowledging that you're doing it - and what you're doing differently than the last seven - will be per se evidence of automated behavior and result in an immediate ban.
- locked and limited conversation to collaborators
on Sep 28, 2026
The following gives me an unexpected "TS1007: Jump target cannot cross function boundary error" in TS 3.3.33333
Further investigation... you can jump to the start of the loop, so the error I would argue is that the error message is confusing.
shareable link