fixes #20227; skip distinct types for genObjConstr [JS backend] (#20229)

fixes #20227; skip distinct types for genObjConstr
This commit is contained in:
ringabout
2022-08-24 19:31:44 +08:00
committed by GitHub
parent b8dc58d884
commit e832fea160
2 changed files with 19 additions and 1 deletions

View File

@@ -2272,6 +2272,7 @@ proc genObjConstr(p: PProc, n: PNode, r: var TCompRes) =
r.kind = resExpr
var initList : Rope
var fieldIDs = initIntSet()
let nTyp = n.typ.skipTypes(abstractInst)
for i in 1..<n.len:
if i > 1: initList.add(", ")
var it = n[i]
@@ -2280,7 +2281,7 @@ proc genObjConstr(p: PProc, n: PNode, r: var TCompRes) =
gen(p, val, a)
var f = it[0].sym
if f.loc.r == nil: f.loc.r = mangleName(p.module, f)
fieldIDs.incl(lookupFieldAgain(n.typ, f).id)
fieldIDs.incl(lookupFieldAgain(nTyp, f).id)
let typ = val.typ.skipTypes(abstractInst)
if a.typ == etyBaseIndex:

View File

@@ -0,0 +1,17 @@
discard """
targets: "c cpp js"
"""
# bug #20227
type
Data = object
id: int
Test = distinct Data
Object = object
data: Test
var x: Object = Object(data: Test(Data(id: 12)))
doAssert Data(x.data).id == 12