mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 14:00:35 +00:00
fixes lifting subtype calling parent's hooks (#23612)
ref https://forum.nim-lang.org/t/11587 Tested with `gcc version 14.0.1 20240412` locally
This commit is contained in:
@@ -222,7 +222,10 @@ proc fillBodyObj(c: var TLiftCtx; n, body, x, y: PNode; enforceDefaultOp: bool)
|
||||
|
||||
proc fillBodyObjTImpl(c: var TLiftCtx; t: PType, body, x, y: PNode) =
|
||||
if t.baseClass != nil:
|
||||
fillBody(c, skipTypes(t.baseClass, abstractPtrs), body, x, y)
|
||||
let obj = newNodeIT(nkHiddenSubConv, c.info, t.baseClass)
|
||||
obj.add newNodeI(nkEmpty, c.info)
|
||||
obj.add x
|
||||
fillBody(c, skipTypes(t.baseClass, abstractPtrs), body, obj, y)
|
||||
fillBodyObj(c, t.n, body, x, y, enforceDefaultOp = false)
|
||||
|
||||
proc fillBodyObjT(c: var TLiftCtx; t: PType, body, x, y: PNode) =
|
||||
|
||||
@@ -136,4 +136,27 @@ proc main2 =
|
||||
doAssert a.len == 2
|
||||
doAssert b.len == 0
|
||||
|
||||
main2()
|
||||
main2()
|
||||
|
||||
block:
|
||||
type
|
||||
TestObj = object of RootObj
|
||||
name: string
|
||||
|
||||
TestSubObj = object of TestObj
|
||||
objname: string
|
||||
|
||||
proc `=destroy`(x: TestObj) =
|
||||
`=destroy`(x.name)
|
||||
|
||||
proc `=destroy`(x: TestSubObj) =
|
||||
`=destroy`(x.objname)
|
||||
`=destroy`(TestObj(x))
|
||||
|
||||
proc testCase() =
|
||||
let t1 {.used.} = TestSubObj(objname: "tso1", name: "to1")
|
||||
|
||||
proc main() =
|
||||
testCase()
|
||||
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user