-
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: crash when passing NimNode to static parameter (#1449)
## Summary * fix a compiler crash when passing a NimNode to a `static` parameter * fix a compiler crash when evaluating a `NimNode`-returning constant expression ## Details There were two problems: * `nkNimNodeLit` wasn't handled in constant data expression by `mirgen` * `NimNode` values returned directly from a VM invocation weren't wrapped in `nkNimNodeLit` trees For handling `NimNode` values in `vm.regToNode`, the existing deserialization logic for `NimNode` values in `vmcompilerserdes` is moved to a separate procedure, so that it can be used by `regToNode`. The `opcRepr` implementation relied on `regToNode` always returning an unwrapped `PNode` -- it is adjusted to manually handle `NimNode` values. A test covering both issues is added. Fixes #1448.
- Loading branch information
Showing
4 changed files
with
38 additions
and
12 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,14 @@ | ||
discard """ | ||
description: ''' | ||
Ensure that a NimNode can be passed as a static parameter to a macro. | ||
''' | ||
action: compile | ||
""" | ||
|
||
import std/macros | ||
|
||
macro m(n: static NimNode) = | ||
doAssert n.kind == nnkStmtList | ||
doAssert n.len == 0 | ||
|
||
m(newStmtList()) |