-
Notifications
You must be signed in to change notification settings - Fork 12.8k
The addition of a continue statement makes the compilation fail #51632
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
Because the code is unreachable, the type narrowing machinery essentially can’t see it. Duplicate of #26914 |
Can't the type narrowing machinery be turned off for unreachable code? |
Well, in a way it already is - any existing narrowings get undone the minute the subsequent code is determined to be unreachable, hence the type errors. You probably meant to ask if type checking can be turned off, and while that’d be an option, there are reasons to keep it on - see #26914 (comment). Note that 26914 is tagged as a bug - it’s something they do want to fix, despite the current design limitations. |
The bug report template asks for plaintext code and a Playground link. A screenshot isn't appropriate for various reasons: you can't copy and paste it into an IDE without an image-to-text step; it's less accessible for visually impaired users who otherwise are able to code; et cetera. Also, this isn't a crash. (Maybe the template should be edited to define the term?) A crash is when the compiler itself fails to run, not when it merely reports warnings for the code it's compiling. If the compiler were a professor and your code were an exam to be graded, it isn't a crash if you disagree with the grade. A crash would be that the professor has a heart attack and dies while grading your exam. |
Thanks for your feedback. I suspected this was already reported in some way. If it would have turned out to be a new bug, I could have provided a playground link. |
Bug Report
The addition of a continue statement in a for loop make some code unreachable (see screenshots below).
After the addition of the continue statement the unreachable part of the code gives compilation errors. The errors are also highlighted in VS Code.
If no continue statement is present everything compiles without an error.
🔎 Search Terms
continue
🕗 Version & Regression Information
I saw the bug today, in tsc version 4.8.4
Please keep and fill in the line that best applies:
-->
🙁 Actual behavior
Not working:

Working

🙂 Expected behavior
The addition of the continue statement shouldn't yield additional compilation errors, especially since they happen in unreachable code.
The text was updated successfully, but these errors were encountered: