-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(compiler): type errors are resolved as
any
type by the type che…
…cker (#2924) See #884 Since type errors resolved as `any` type by the type checker we don't have a cleat way to distinguish unresolved types from valid `any` types. This can lead to bug downstream where a symbol with an unknown type is accessed as if it's an `any` without the compiler noticing it. In practice this usually isn't a problem since type errors lead to a diagnostic which leads to a compilation failure so we never get too far downstream with this. But correctness is important here: * There might be cases we aren't aware of. * A dedicated error-type can be used for additional diagnostics like location where the type resolving failed. * We are now more explicit in the code about ignore cascading errors as opposed to handing an any type. - [x] ~~As of now I don't have a good test for this showing how using an `any` type creates an error where it's illegal compared to ignoring that error in case of a cascading type error.~~ But I'm working on finding such a case... **update:** The one case that's relevant that I could find is that unknown symbols are now "unresolved types" which means we don't need to check if they are reassignable in assignment statements, previously they were any types which lead to an additional redundant error (can't reassign to a non-reassignable). Updated snapshot test accordingly. The PR also cleans up some type checking code and produces slightly better diags in some cases while eliminating diags which where redundant (see snapshot). This PR also changes the LSP to eagerly load submodule types when needed in the completion logic instead of during the type checking phase. This is a revised fix of #2921. ## Checklist - [x] Title matches [Winglang's style guide](https://docs.winglang.io/contributors/pull_requests#how-are-pull-request-titles-formatted) - [x] Description explains motivation and solution - [ ] Tests added (always) - [ ] Docs updated (only required for features) - [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Monada Contribution License](https://docs.winglang.io/terms-and-policies/contribution-license.html)*.
- Loading branch information
1 parent
1026d18
commit 7513700
Showing
12 changed files
with
263 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,6 @@ class SomeResource { | |
class A extends B { | ||
//^ Unknown symbol | ||
} | ||
|
||
unknown = 1; | ||
//^ Unknown symbol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.