-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Confusing error message for labels used before definition #30408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Seems like a reasonable request. |
Here'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:
To find if it's applicable, walk up each scope until the first functionlike ( We can also provide a related span. We already have a diagnostic for
|
??????
Get Outlook for Android<https://aka.ms/ghei36>
…________________________________
From: Daniel Rosenwasser <[email protected]>
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>.
|
Actually, we already have a better message for |
In 3.4?
Get Outlook for Android<https://aka.ms/ghei36>
…________________________________
From: Daniel Rosenwasser <[email protected]>
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>.
|
Hey -- is this still something that should be implemented? Happy to make changes now if no one else is already |
Yes, please. This is still an issue in @next |
It may be a bit more work than I originally anticipated (since labels aren't placed in any sort of scope), but we're taking PRs if you're up for it. I guess if you can walk up the tree and look for labels in each enclosing scope, then:
In the first two, give the appropriate related span mentioned above. |
@laurafiuza Still working on this? |
@DanielRosenwasser For point 1, we will have to go through the entire set of statements in the source file to check if the label exists as, as soon as we travel up the tree and go beyond the function boundry we get the source file in the example in the first example. To simply put we will have to check the siblings of the function statement. Is my understanding right? |
I would avoid trying to walk through every scope. Try going with this initial suggestion (though ensure you don't go past the
Just scan through the statements at each level until you hit a function-like/class-like - don't try to walk recursively. |
@DanielRosenwasser This is what is already being done. The cross boundary error is returned as soon as the first functionlike statment is found. |
you could have thrown a better error message, talking about this: https://stackoverflow.com/questions/59859011/break-says-error-jump-target-cannot-cross-function-boundary-typescript/59859151#59859151 |
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
The text was updated successfully, but these errors were encountered: