fixes #5892
This commit is contained in:
parent
30e2af969c
commit
81ce73db94
2 changed files with 27 additions and 4 deletions
|
|
@ -744,14 +744,17 @@ proc genTupleElem(p: BProc, e: PNode, d: var TLoc) =
|
||||||
addf(r, ".Field$1", [rope(i)])
|
addf(r, ".Field$1", [rope(i)])
|
||||||
putIntoDest(p, d, tupType.sons[i], r, a.s)
|
putIntoDest(p, d, tupType.sons[i], r, a.s)
|
||||||
|
|
||||||
proc lookupFieldAgain(p: BProc, ty: PType; field: PSym; r: var Rope): PSym =
|
proc lookupFieldAgain(p: BProc, ty: PType; field: PSym; r: var Rope;
|
||||||
|
resTyp: ptr PType = nil): PSym =
|
||||||
var ty = ty
|
var ty = ty
|
||||||
assert r != nil
|
assert r != nil
|
||||||
while ty != nil:
|
while ty != nil:
|
||||||
ty = ty.skipTypes(skipPtrs)
|
ty = ty.skipTypes(skipPtrs)
|
||||||
assert(ty.kind in {tyTuple, tyObject})
|
assert(ty.kind in {tyTuple, tyObject})
|
||||||
result = lookupInRecord(ty.n, field.name)
|
result = lookupInRecord(ty.n, field.name)
|
||||||
if result != nil: break
|
if result != nil:
|
||||||
|
if resTyp != nil: resTyp[] = ty
|
||||||
|
break
|
||||||
if not p.module.compileToCpp: add(r, ".Sup")
|
if not p.module.compileToCpp: add(r, ".Sup")
|
||||||
ty = ty.sons[0]
|
ty = ty.sons[0]
|
||||||
if result == nil: internalError(field.info, "genCheckedRecordField")
|
if result == nil: internalError(field.info, "genCheckedRecordField")
|
||||||
|
|
@ -768,8 +771,9 @@ proc genRecordField(p: BProc, e: PNode, d: var TLoc) =
|
||||||
addf(r, ".Field$1", [rope(f.position)])
|
addf(r, ".Field$1", [rope(f.position)])
|
||||||
putIntoDest(p, d, f.typ, r, a.s)
|
putIntoDest(p, d, f.typ, r, a.s)
|
||||||
else:
|
else:
|
||||||
let field = lookupFieldAgain(p, ty, f, r)
|
var rtyp: PType
|
||||||
if field.loc.r == nil: fillObjectFields(p.module, ty)
|
let field = lookupFieldAgain(p, ty, f, r, addr rtyp)
|
||||||
|
if field.loc.r == nil and rtyp != nil: fillObjectFields(p.module, rtyp)
|
||||||
if field.loc.r == nil: internalError(e.info, "genRecordField 3 " & typeToString(ty))
|
if field.loc.r == nil: internalError(e.info, "genRecordField 3 " & typeToString(ty))
|
||||||
addf(r, ".$1", [field.loc.r])
|
addf(r, ".$1", [field.loc.r])
|
||||||
putIntoDest(p, d, field.typ, r, a.s)
|
putIntoDest(p, d, field.typ, r, a.s)
|
||||||
|
|
|
||||||
|
|
@ -89,3 +89,22 @@ echo sizeof(testObject_1)
|
||||||
echo sizeof(testObject_2)
|
echo sizeof(testObject_2)
|
||||||
echo sizeof(testObject_3[int64])
|
echo sizeof(testObject_3[int64])
|
||||||
echo sizeof(testObject_4[int64])
|
echo sizeof(testObject_4[int64])
|
||||||
|
|
||||||
|
# bug #5892
|
||||||
|
type
|
||||||
|
Foo6 = distinct array[4, float32]
|
||||||
|
AnotherFoo = distinct array[4, float32]
|
||||||
|
|
||||||
|
AbstractAnimationSampler* = ref object of RootObj
|
||||||
|
|
||||||
|
AnimationSampler*[T] = ref object of AbstractAnimationSampler
|
||||||
|
sampleImpl: proc(s: AnimationSampler[T], p: float): T
|
||||||
|
|
||||||
|
ArrayAnimationSampler*[T] = ref object of AnimationSampler[T]
|
||||||
|
|
||||||
|
proc newArrayAnimationSampler*[T](): ArrayAnimationSampler[T] =
|
||||||
|
result.new()
|
||||||
|
result.sampleImpl = nil
|
||||||
|
|
||||||
|
discard newArrayAnimationSampler[Foo6]()
|
||||||
|
discard newArrayAnimationSampler[AnotherFoo]()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue