fixes #25167; fixes deref type (#25195)

fixes #25167
This commit is contained in:
ringabout
2025-09-26 22:12:34 +08:00
committed by GitHub
parent 9f74712ec6
commit fed0053481
2 changed files with 11 additions and 1 deletions

View File

@@ -834,7 +834,9 @@ proc transformFor(c: PTransf, n: PNode): PNode =
var temp = newTemp(c, arg[0].typ, formal.info)
addVar(v, temp)
stmtList.add(newAsgnStmt(c, nkFastAsgn, temp, arg[0], true))
newC.mapping[formal.itemId] = newDeref(temp)
let newD = newDeref(temp)
newD.typ() = t
newC.mapping[formal.itemId] = newD
else:
# generate a temporary and produce an assignment statement:
var temp = newTemp(c, t, formal.info)

View File

@@ -424,3 +424,11 @@ block: # bug #25121
for _ in k():
(proc() = (; let _ = block: 0))()
let aaa = new array[1000, byte]
block:
for _ in cast[typeof(aaa)](aaa)[]:
discard
block:
let x = cast[typeof(aaa)](aaa) # not even var
for _ in x[]:
discard