mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-05 03:14:08 +00:00
fixes ilegal recursion (#22105)
This commit is contained in:
@@ -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
|
||||
|
||||
6
tests/objects/tillegal_recursion2.nim
Normal file
6
tests/objects/tillegal_recursion2.nim
Normal file
@@ -0,0 +1,6 @@
|
||||
discard """
|
||||
errormsg: "Cannot inherit from: 'Foo'"
|
||||
line: 6
|
||||
"""
|
||||
type
|
||||
Foo = object of Foo
|
||||
6
tests/objects/tillegal_recursion3.nim
Normal file
6
tests/objects/tillegal_recursion3.nim
Normal file
@@ -0,0 +1,6 @@
|
||||
discard """
|
||||
errormsg: "Cannot inherit from: 'Foo'"
|
||||
line: 6
|
||||
"""
|
||||
type
|
||||
Foo = object of ref Foo
|
||||
Reference in New Issue
Block a user