-
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.
sem: fix crash due to incorrect error handling (#1372)
## Summary Wrap usage of erroneous symbols in quiet errors, so that error propagation works as expected. This fixes compiler/nimsuggest crashes when the iterable expression in `for` loops has an error. Fixes #1369. ## Details ### The Problem If the iterable slot of a `for` loop is an error, `tyError` is assigned as the forvars' type. When such forvar appears as an argument in a call expression, errors ### The Solution * add the `adWrappedSymError` diagnostic, which is a quiet diagnostic like `adWrappedError`, meaning that it's only used for error propagation and never reported * move `newSymNode2` from `ast` to `sem` and change it so that it creates `adWrappedSymError` error nodes for symbols where the definition has an error * rename `newSymNode2` to `newSymNodeOrError` * update the few usages of `newSymNode2` * add test for the `for`-loop-related compiler crash to the new `error_propagation` category The introduction of `adWrappedSymError` is meant to be a foundational work for changing `skError` to only represent errors (instead of both errors and symbols whose definition has an error).
- Loading branch information
Showing
9 changed files
with
37 additions
and
40 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
discard """ | ||
description: ''' | ||
Ensure for-loop vars are usable in call expressions when the iterable slot | ||
has an error. | ||
''' | ||
matrix: "--errorMax:100" | ||
errormsg: "undeclared identifier: 'unknown'" | ||
line: 11 | ||
""" | ||
|
||
for x in unknown: | ||
echo x |