Skip to content

Commit

Permalink
test vm
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout committed May 15, 2023
1 parent f4a9b25 commit f33aed0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions compiler/vm.nim
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,9 @@ 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 = src[rc].skipColon
regs[ra].node = n
else:
let n = src[rc]
regs[ra].node = n
Expand Down
8 changes: 7 additions & 1 deletion compiler/vmgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1888,7 +1888,13 @@ proc getNullValue(typ: PType, info: TLineInfo; conf: ConfigRef): PNode =
of tyTuple:
result = newNodeIT(nkTupleConstr, info, t)
for i in 0..<t.len:
result.add getNullValue(t[i], info, conf)
if t.n == nil:
result.add getNullValue(t[i], info, conf)
else:
result.add newTree(nkExprColonExpr,
t.n[i],
getNullValue(t[i], info, conf)
)
of tySet:
result = newNodeIT(nkCurly, info, t)
of tySequence, tyOpenArray:
Expand Down
10 changes: 10 additions & 0 deletions tests/vm/tvmmisc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit f33aed0

Please sign in to comment.