fixes #21708; skip colons for tuples in VM (#21850)

* fixes #21708; skip colon for tuples in VM

* skip nimnodes

* fixes types
This commit is contained in:
ringabout
2023-05-17 06:20:40 +08:00
committed by GitHub
parent ce1ba91573
commit eecf12c4b5
2 changed files with 17 additions and 1 deletions

View File

@@ -20,7 +20,7 @@ import
when defined(nimPreviewSlimSystem):
import std/formatfloat
import astalgo
import ast except getstr
from semfold import leValueConv, ordinalValToString
from evaltempl import evalTemplate
@@ -844,6 +844,12 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
of nkObjConstr:
let n = src[rc + 1].skipColon
regs[ra].node = n
of nkTupleConstr:
let n = if src.typ != nil and tfTriggersCompileTime in src.typ.flags:
src[rc]
else:
src[rc].skipColon
regs[ra].node = n
else:
let n = src[rc]
regs[ra].node = n

View File

@@ -688,3 +688,13 @@ block: # bug #7590
# const c=(foo:(bar1: 0.0))
const c=(foo:(bar1:"foo1"))
fun2(c)
block: # bug #21708
type
Tup = tuple[name: string]
const X: array[2, Tup] = [(name: "foo",), (name: "bar",)]
static:
let s = X[0]
doAssert s[0] == "foo"