parent
e4aadcf1c1
commit
2564b5c938
2 changed files with 34 additions and 4 deletions
|
|
@ -499,10 +499,20 @@ proc propagateFieldFlags(t: PType, n: PNode) =
|
||||||
|
|
||||||
proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType =
|
proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType =
|
||||||
template bailout =
|
template bailout =
|
||||||
if t.sym != nil and sfGeneratedType in t.sym.flags:
|
if (t.sym == nil) or (t.sym != nil and sfGeneratedType in t.sym.flags):
|
||||||
# Only consider the recursion limit if the symbol is a type with generic
|
# In the first case 't.sym' can be 'nil' if the type is a ref/ptr, see
|
||||||
# parameters that have not been explicitly supplied, typechecking should
|
# issue https://github.com/nim-lang/Nim/issues/20416 for more details.
|
||||||
# terminate when generic parameters are explicitly supplied.
|
# Fortunately for us this works for now because partial ref/ptr types are
|
||||||
|
# not allowed in object construction, eg.
|
||||||
|
# type
|
||||||
|
# Container[T] = ...
|
||||||
|
# O = object
|
||||||
|
# val: ref Container
|
||||||
|
#
|
||||||
|
# In the second case only consider the recursion limit if the symbol is a
|
||||||
|
# type with generic parameters that have not been explicitly supplied,
|
||||||
|
# typechecking should terminate when generic parameters are explicitly
|
||||||
|
# supplied.
|
||||||
if cl.recursionLimit > 100:
|
if cl.recursionLimit > 100:
|
||||||
# bail out, see bug #2509. But note this caching is in general wrong,
|
# bail out, see bug #2509. But note this caching is in general wrong,
|
||||||
# look at this example where TwoVectors should not share the generic
|
# look at this example where TwoVectors should not share the generic
|
||||||
|
|
|
||||||
|
|
@ -872,3 +872,23 @@ block: # Ensure no segfault from constraint
|
||||||
a = Regex[int]()
|
a = Regex[int]()
|
||||||
b = Regex[bool]()
|
b = Regex[bool]()
|
||||||
c = MyOtherType[seq[int]]()
|
c = MyOtherType[seq[int]]()
|
||||||
|
|
||||||
|
block: # https://github.com/nim-lang/Nim/issues/20416
|
||||||
|
type
|
||||||
|
Item[T] = object
|
||||||
|
link:ptr Item[T]
|
||||||
|
data:T
|
||||||
|
|
||||||
|
KVSeq[A,B] = seq[(A,B)]
|
||||||
|
|
||||||
|
MyTable[A,B] = object
|
||||||
|
data: KVSeq[A,B]
|
||||||
|
|
||||||
|
Container[T] = object
|
||||||
|
a: MyTable[int,ref Item[T]]
|
||||||
|
|
||||||
|
proc p1(sg:Container) = discard # Make sure that a non parameterized 'Container' argument still compiles
|
||||||
|
|
||||||
|
proc p2[T](sg:Container[T]) = discard
|
||||||
|
var v : Container[int]
|
||||||
|
p2(v)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue