-
Notifications
You must be signed in to change notification settings - Fork 27.2k
fix(compiler-cli): report diagnostic instead of crashing on malformed… #69441
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -337,8 +337,11 @@ export class IncrementalCompilation implements IncrementalBuild<ClassRecord, Fil | |
| } | ||
|
|
||
| priorTypeCheckingResultsFor(sf: ts.SourceFile): FileTypeCheckingData | null { | ||
| // In some environments (e.g., language service during edits), type-check queries can occur | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure about the implications of this on the language service. cc @atscott
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm well certainly errors are never good for language service if not caught but this seems like a suspicious place to fix it. Probably needs something higher up?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the feedback! Looking "higher up" in the stack, analyzeTrait in Would the right direction be to generalize that catch so any unexpected error during directive analysis becomes a diagnostic instead of being re-thrown? That would protect the LS from this and similar future bugs in any handler, not just host-bindings. Happy to update the PR to take that approach if it sounds right to you. |
||
| // before the compiler has fully transitioned to the TypeCheckAndEmit phase. In such cases we | ||
| // cannot adopt prior results safely, so return null instead of throwing an assertion. | ||
| if (this.phase.kind !== PhaseKind.TypeCheckAndEmit) { | ||
| throw new Error(`AssertionError: Expected successfully analyzed compilation.`); | ||
| return null; | ||
| } | ||
|
|
||
| if (this.step === null) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment isn’t needed, please remove.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also seems a bit of an odd choice. Why not change the parsing function to throw fatal diagnostics instead of plain errors if it’s not allowed to throw errors