-
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
.line
pragma ignoring column information (#860)
## Summary Use the column information provided by the tuple value, which fixes, for example, stack traces produced by assertion failures in compile-time contexts pointing to the wrong column. In addition, the tuple passed to the `.line` pragma is now verified to have the correct number of elements, which fixes the compiler crashing when it's a tuple with less than the expected number of elements. ## Details In `pragmaLine`: - don't allow `nkPar` -- all literal tuple construction expressions have to use `nkTupleConstr` nodes - require the provided tuple node to have exactly three elements - use more descriptive names instead of `x` and `y` - use the third tuple element's value (which is required to be an integer value) as the column information - build the `TLineInfo` with `newLineInfo`, which also makes sure that out-of-range line and column numbers are properly handled (by clamping them) - use the correct node when creating errors and use `wrapError` for proper propagation In addition, the error message for when the provided tuple value doesn't have the correct shape is slightly improved, now detailing how the tuple is required to look like. A test (`t9768.nim`) that relied on incorrect column being set is adjusted.
- Loading branch information
Showing
4 changed files
with
29 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
discard """ | ||
errormsg: "a tuple value of the form '(string, int, int)' is expected, but got: '(\"\",)'" | ||
line: 6 | ||
""" | ||
|
||
{.line: ("",).}: | ||
discard |
9efc16f
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.
how this takes effect? I thought without line pragma param it should go to
n.info = getInfoContext(c.config, -1)
while this patch only change if branch. I try to port this to my nim's PR still gett9768.nim(23, 3) foo1
9efc16f
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.
found nim error message is "t9768.nim(24, 3)
a < 4
", while here is "t9768.nim(23, 12)" there must has difference in other place