fixes ilegal recursion (#22105)

This commit is contained in:
Juan M Gómez
2023-06-16 07:23:25 +01:00
committed by GitHub
parent 0a19d78b22
commit b4d9be0f8a
3 changed files with 15 additions and 1 deletions

View File

@@ -376,7 +376,9 @@ proc semConstructTypeAux(c: PContext,
if status in {initPartial, initNone, initUnknown}:
discard collectMissingFields(c, t.n, constrCtx, result.defaults)
let base = t[0]
if base == nil: break
if base == nil or base.id == t.id or
base.kind in { tyRef, tyPtr } and base[0].id == t.id:
break
t = skipTypes(base, skipPtrs)
if t.kind != tyObject:
# XXX: This is not supposed to happen, but apparently

View File

@@ -0,0 +1,6 @@
discard """
errormsg: "Cannot inherit from: 'Foo'"
line: 6
"""
type
Foo = object of Foo

View File

@@ -0,0 +1,6 @@
discard """
errormsg: "Cannot inherit from: 'Foo'"
line: 6
"""
type
Foo = object of ref Foo