-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(sem): crash with erroneous
is
expression (#1485)
## Summary Fix a crash with erroneous `is` expressions appearing directly as a `when` conditions expressions causing the compiler to crash. ## Details There were two issues: 1. `semIs` modified input AST, which led to the error correction in the `fitNode` called by `forceBool` called by `semWhen` not triggering 2. `semWhen` used the `semConstExpr`, which doesn't return an `nkError` on failure, thus leading to a field access defect when happening in a context where `localReport` doesn't terminate the compiler `semIs` is changed to not modify input AST. In addition, the workaround for `is` being analyzed eagerly in generic expression is removed, as it's no longer needed. In `semWhen`, the usage of `semConstExpr` is replaced with `semRealConstExpr`, which properly propagates `nkError`. The latter was missing execution context handling (needed for detecting illegal `break`s crossing the compile-time / run-time boundary), which is now fixed too. Fixes #1483.
- Loading branch information
Showing
3 changed files
with
30 additions
and
21 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
discard """ | ||
errormsg: "undeclared identifier: 'missing'" | ||
""" | ||
|
||
var x = missing | ||
when x is int: | ||
discard |