Skip to content

Commit 39be9b9

Browse files
authored
fixes #25227; crash when codegen user-defined tuple iterate (#25228)
fixes #25227
1 parent 9becd14 commit 39be9b9

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

compiler/ccgexprs.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ proc genTupleElem(p: BProc, e: PNode, d: var TLoc) =
10061006
var
10071007
i: int = 0
10081008
var a: TLoc = initLocExpr(p, e[0])
1009-
let tupType = a.t.skipTypes(abstractInst+{tyVar})
1009+
let tupType = a.t.skipTypes(abstractInst+{tyVar}+tyUserTypeClasses) # ref #25227
10101010
assert tupType.kind == tyTuple
10111011
d.inheritLocation(a)
10121012
discard getTypeDesc(p.module, a.t) # fill the record's fields.loc

compiler/jsgen.nim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1375,7 +1375,8 @@ proc genFieldAddr(p: PProc, n: PNode, r: var TCompRes) =
13751375
r.typ = etyBaseIndex
13761376
let b = if n.kind == nkHiddenAddr: n[0] else: n
13771377
gen(p, b[0], a)
1378-
if skipTypes(b[0].typ, abstractVarRange).kind == tyTuple:
1378+
if skipTypes(b[0].typ, abstractVarRange + tyTypeClasses).kind == tyTuple:
1379+
# ref #25227 about `+ tyTypeClasses`
13791380
r.res = makeJSString("Field" & $getFieldPosition(p, b[1]))
13801381
else:
13811382
if b[1].kind != nkSym: internalError(p.config, b[1].info, "genFieldAddr")

0 commit comments

Comments
 (0)