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.
Summary
static
parameterNimNode
-returning constant expressionDetails
There were two problems:
nkNimNodeLit
wasn't handled in constant data expression bymirgen
NimNode
values returned directly from a VM invocation weren't wrapped innkNimNodeLit
treesFor handling
NimNode
values invm.regToNode
, the existing deserialization logic forNimNode
values invmcompilerserdes
is moved to a separate procedure, so that it can be used byregToNode
.The
opcRepr
implementation relied onregToNode
always returning an unwrappedPNode
-- it is adjusted to manually handleNimNode
values.A test covering both issues is added.
Fixes https://github.com/nim-works/nimskull/issues/1448.