Generic tuple recursion fix (#11115)

* fixes #1145
* unify error messages
This commit is contained in:
Arne Döring 2019-04-28 10:11:41 +02:00 • committed by Andreas Rumpf
commit a432aedb54
4 changed files with 13 additions and 4 deletions

View file

@ -1348,8 +1348,8 @@ proc semGeneric(c: PContext, n: PNode, s: PSym, prev: PType): PType =
# special check for generic object with # special check for generic object with
# generic/partial specialized parent # generic/partial specialized parent
let tx = result.skipTypes(abstractPtrs, 50) let tx = result.skipTypes(abstractPtrs, 50)
if tx.isNil: if tx.isNil or isTupleRecursive(tx):
localError(c.config, n.info, "invalid recursion in type '$1'" % typeToString(result[0])) localError(c.config, n.info, "illegal recursion in type '$1'" % typeToString(result[0]))
return errorType(c) return errorType(c)
if tx != result and tx.kind == tyObject and tx.sons[0] != nil: if tx != result and tx.kind == tyObject and tx.sons[0] != nil:
semObjectTypeForInheritedGenericInst(c, n, tx) semObjectTypeForInheritedGenericInst(c, n, tx)

View file

@ -1,5 +1,5 @@
discard """ discard """
errormsg: "illegal recursion in type 'RefTreeInt'" errormsg: "illegal recursion in type 'RefTree'"
""" """
type type

View file

@ -0,0 +1,9 @@
discard """
errormsg: "illegal recursion in type 'TPearl'"
"""
type
TPearl[T] = tuple
next: TPearl[T]
var x: TPearl[int]

View file

@ -1,5 +1,5 @@
discard """ discard """
errormsg: "invalid recursion in type 'Executor'" errormsg: "illegal recursion in type 'Executor'"
line: 8 line: 8
""" """
# bug reported by PR #5637 # bug reported by PR #5637