mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
Generic tuple recursion fix (#11115)
* fixes #1145 * unify error messages
This commit is contained in:
committed by
Andreas Rumpf
parent
da3b649539
commit
a432aedb54
@@ -1348,8 +1348,8 @@ proc semGeneric(c: PContext, n: PNode, s: PSym, prev: PType): PType =
|
||||
# special check for generic object with
|
||||
# generic/partial specialized parent
|
||||
let tx = result.skipTypes(abstractPtrs, 50)
|
||||
if tx.isNil:
|
||||
localError(c.config, n.info, "invalid recursion in type '$1'" % typeToString(result[0]))
|
||||
if tx.isNil or isTupleRecursive(tx):
|
||||
localError(c.config, n.info, "illegal recursion in type '$1'" % typeToString(result[0]))
|
||||
return errorType(c)
|
||||
if tx != result and tx.kind == tyObject and tx.sons[0] != nil:
|
||||
semObjectTypeForInheritedGenericInst(c, n, tx)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
errormsg: "illegal recursion in type 'RefTreeInt'"
|
||||
errormsg: "illegal recursion in type 'RefTree'"
|
||||
"""
|
||||
|
||||
type
|
||||
|
||||
9
tests/types/tillegaltuplerecursiongeneric2.nim
Normal file
9
tests/types/tillegaltuplerecursiongeneric2.nim
Normal file
@@ -0,0 +1,9 @@
|
||||
discard """
|
||||
errormsg: "illegal recursion in type 'TPearl'"
|
||||
"""
|
||||
|
||||
type
|
||||
TPearl[T] = tuple
|
||||
next: TPearl[T]
|
||||
|
||||
var x: TPearl[int]
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
errormsg: "invalid recursion in type 'Executor'"
|
||||
errormsg: "illegal recursion in type 'Executor'"
|
||||
line: 8
|
||||
"""
|
||||
# bug reported by PR #5637
|
||||
|
||||
Reference in New Issue
Block a user