-
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(js): wrong code for uninitialized
pointer
locals (#1011)
## Summary Fix wrong code being generated for uninitialized locals of `pointer` type, which resulted in run-time crashes or other unexpected behaviour. ## Details * the set used in deciding whether to use a boxed pointer missed `tyPointer`. Since testing the set after the inclusion of `tyPointer` would be redundant with the `mapType` check, testing the set is simply removed * the `not isIndirect` check is replaced with testing whether a boxed pointer is used. While a loc using an indirection implies a boxed representation, the extra indirection made the logic harder to understand
- Loading branch information
Showing
2 changed files
with
18 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
discard """ | ||
description: ''' | ||
Regression test for wrong code being generated for locals of `pointer` | ||
type | ||
''' | ||
""" | ||
|
||
proc test(): pointer = | ||
# the result variable was affected too | ||
var x: pointer | ||
doAssert x == nil # this assertion failed | ||
|
||
doAssert test() == nil # this one too |