-
Notifications
You must be signed in to change notification settings - Fork 195
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
chore(compiler): type references as expressions and phase tracking #3177
Conversation
No functional changes, preparatory pull request as part of the expression lifting escapade. To support expression lifting, the type checker now records the phase of each expression during type checking and makes it available through `get_expr_phase`. Additionally, turn the variable component of `StmtKind::Assignment` from a simple `Symbol` to an `Expr` in order for it to also hold type and phase information. The JSII importer accidentally imported structs as `preflight` while they should be phase-independent. Misc: strip excess newlines when adding a line to `CodeMaker`.
Signed-off-by: monada-bot[bot] <[email protected]>
phase
to each expression during type checkingThere 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.
Thanks to the detailed PR description reviewing was a breeze...
Fixes #2916 by returning exit code 0 when tests fail. ## Misc Tweaks to a bunch of tests. ## Checklist - [x] Title matches [Winglang's style guide](https://docs.winglang.io/contributing/pull_requests#how-are-pull-request-titles-formatted) - [x] Description explains motivation and solution - [x] Tests added (always) - [x] Docs updated (only required for features) - [x] 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)*.
@MarkMcCulloh I'll make sure all the diagnostics around base classes are fixed. If that's all, I'd appreciate an approval so I can be unblocked with my next step. |
Signed-off-by: monada-bot[bot] <[email protected]>
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.
I'll make sure all the diagnostics around base classes are fixed. If that's all, I'd appreciate an approval so I can be unblocked with my next step.
Yeah LGTM as long as the diags are fixed. Luckily the grammar still prevents real expressions into places where types are expected so we might be safe from some new big regressions.
I also think @yoav-steinberg should take a look at this, but I'll leave that to you if you want to wait.
Signed-off-by: monada-bot[bot] <[email protected]>
Thanks. I'll check with @yoav-steinberg if he is available |
Co-authored-by: Chris Rybicki <[email protected]>
Co-authored-by: Chris Rybicki <[email protected]>
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Signed-off-by: monada-bot[bot] <[email protected]>
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Congrats! 🚀 This was released in Wing 0.23.5. |
…3177) No functional changes, preparatory pull request as part of the expression lifting escapade. Type references are expressions that reference type names. It's valuable to model them as expressions because they are needed at runtime. Once they are modeled as expressions, we can treat all expressions equally when it comes to lifting (which is the motivation for this refactor). We've changed the following places to use type references instead of a `UserDefinedType`. In all of these cases the types have a runtime presence. The rest of the places are just type annotations that are erased at runtime: - The class being instantiated in `new` expressions - Base classes - The type component in a `Reference::TypeMember` (static access). Furthermore, to support expression lifting, the type checker now records the phase of each expression during type checking and makes it available through `get_expr_phase`. Additionally, changed the left-hand-side of an assignment statement to be an `Expr` and not a `Reference`. Also in order to be able to lift it. Turn the variable component of `StmtKind::Assignment` from a simple `Symbol` to an `Expr` in order for it to also hold type and phase information. The JSII importer accidentally imported structs as `preflight` while they should be phase-independent. Misc: strip excess newlines when adding a line to `CodeMaker`. ## Checklist - [x] Title matches [Winglang's style guide](https://docs.winglang.io/contributing/pull_requests#how-are-pull-request-titles-formatted) - [x] Description explains motivation and solution - [x] Tests added (always) - [x] Docs updated (only required for features) - [x] 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)*.
examples/tests/invalid/enums.w
Outdated
@@ -2,8 +2,8 @@ enum SomeEnum { | |||
ONE, TWO, THREE | |||
} | |||
|
|||
let four = SomeEnum.FOUR; | |||
// ERR ^^^^ enum value does not exist | |||
// let four = SomeEnum.FOUR; |
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.
Is that commented out on purpose?
No functional changes, preparatory pull request as part of the expression lifting escapade.
Type references are expressions that reference type names. It's valuable to model them as expressions because they are needed at runtime. Once they are modeled as expressions, we can treat all expressions equally when it comes to lifting (which is the motivation for this refactor).
We've changed the following places to use type references instead of a
UserDefinedType
. In all of these cases the types have a runtime presence. The rest of the places are just type annotations that are erased at runtime:new
expressionsReference::TypeMember
(static access).Furthermore, to support expression lifting, the type checker now records the phase of each expression during type checking and makes it available through
get_expr_phase
.Additionally, changed the left-hand-side of an assignment statement to be an
Expr
and not aReference
. Also in order to be able to lift it.Turn the variable component of
StmtKind::Assignment
from a simpleSymbol
to anExpr
in order for it to also hold type and phase information.The JSII importer accidentally imported structs as
preflight
while they should be phase-independent.Misc: strip excess newlines when adding a line to
CodeMaker
.Checklist
pr/e2e-full
label if this feature requires end-to-end testingBy submitting this pull request, I confirm that my contribution is made under the terms of the Monada Contribution License.