fix #931 and few more tests
This commit is contained in:
parent
f13a836972
commit
0bbf6081d0
4 changed files with 17 additions and 17 deletions
|
|
@ -705,7 +705,6 @@ proc liftParamType(c: PContext, procKind: TSymKind, genericParams: PNode,
|
||||||
# result.rawAddSon(copyType(paramType.sons[i], getCurrOwner(), true))
|
# result.rawAddSon(copyType(paramType.sons[i], getCurrOwner(), true))
|
||||||
result = instGenericContainer(c, paramType.sym.info, result,
|
result = instGenericContainer(c, paramType.sym.info, result,
|
||||||
allowMetaTypes = true)
|
allowMetaTypes = true)
|
||||||
result.lastSon.shouldHaveMeta
|
|
||||||
result = newTypeWithSons(c, tyCompositeTypeClass, @[paramType, result])
|
result = newTypeWithSons(c, tyCompositeTypeClass, @[paramType, result])
|
||||||
result = addImplicitGeneric(result)
|
result = addImplicitGeneric(result)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -220,7 +220,7 @@ proc handleGenericInvokation(cl: var TReplTypeVars, t: PType): PType =
|
||||||
# is difficult to handle:
|
# is difficult to handle:
|
||||||
var body = t.sons[0]
|
var body = t.sons[0]
|
||||||
if body.kind != tyGenericBody: internalError(cl.info, "no generic body")
|
if body.kind != tyGenericBody: internalError(cl.info, "no generic body")
|
||||||
var header: PType = nil
|
var header: PType = t
|
||||||
# search for some instantiation here:
|
# search for some instantiation here:
|
||||||
if cl.allowMetaTypes:
|
if cl.allowMetaTypes:
|
||||||
result = PType(idTableGet(cl.localCache, t))
|
result = PType(idTableGet(cl.localCache, t))
|
||||||
|
|
@ -232,11 +232,13 @@ proc handleGenericInvokation(cl: var TReplTypeVars, t: PType): PType =
|
||||||
if x.kind == tyGenericParam:
|
if x.kind == tyGenericParam:
|
||||||
x = lookupTypeVar(cl, x)
|
x = lookupTypeVar(cl, x)
|
||||||
if x != nil:
|
if x != nil:
|
||||||
if header == nil: header = instCopyType(cl, t)
|
if header == t: header = instCopyType(cl, t)
|
||||||
header.sons[i] = x
|
header.sons[i] = x
|
||||||
propagateToOwner(header, x)
|
propagateToOwner(header, x)
|
||||||
|
else:
|
||||||
|
propagateToOwner(header, x)
|
||||||
|
|
||||||
if header != nil:
|
if header != t:
|
||||||
# search again after first pass:
|
# search again after first pass:
|
||||||
result = searchInstTypes(header)
|
result = searchInstTypes(header)
|
||||||
if result != nil: return
|
if result != nil: return
|
||||||
|
|
@ -244,6 +246,7 @@ proc handleGenericInvokation(cl: var TReplTypeVars, t: PType): PType =
|
||||||
header = instCopyType(cl, t)
|
header = instCopyType(cl, t)
|
||||||
|
|
||||||
result = newType(tyGenericInst, t.sons[0].owner)
|
result = newType(tyGenericInst, t.sons[0].owner)
|
||||||
|
result.flags = header.flags
|
||||||
# be careful not to propagate unnecessary flags here (don't use rawAddSon)
|
# be careful not to propagate unnecessary flags here (don't use rawAddSon)
|
||||||
result.sons = @[header.sons[0]]
|
result.sons = @[header.sons[0]]
|
||||||
# ugh need another pass for deeply recursive generic types (e.g. PActor)
|
# ugh need another pass for deeply recursive generic types (e.g. PActor)
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
discard """
|
discard """
|
||||||
msg: '''
|
msg: '''int int
|
||||||
int
|
float float
|
||||||
float
|
int int
|
||||||
TFoo
|
TFoo TFoo
|
||||||
TFoo
|
int float
|
||||||
'''
|
TFoo TFoo'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import typetraits
|
import typetraits
|
||||||
|
|
@ -24,8 +24,7 @@ template reject(e: expr) =
|
||||||
|
|
||||||
proc genericParamRepeated[T: typedesc](a: T, b: T) =
|
proc genericParamRepeated[T: typedesc](a: T, b: T) =
|
||||||
static:
|
static:
|
||||||
echo a.name
|
echo a.name, " ", b.name
|
||||||
echo b.name
|
|
||||||
|
|
||||||
accept genericParamRepeated(int, int)
|
accept genericParamRepeated(int, int)
|
||||||
accept genericParamRepeated(float, float)
|
accept genericParamRepeated(float, float)
|
||||||
|
|
@ -35,8 +34,7 @@ reject genericParamRepeated(int, float)
|
||||||
|
|
||||||
proc genericParamOnce[T: typedesc](a, b: T) =
|
proc genericParamOnce[T: typedesc](a, b: T) =
|
||||||
static:
|
static:
|
||||||
echo a.name
|
echo a.name, " ", b.name
|
||||||
echo b.name
|
|
||||||
|
|
||||||
accept genericParamOnce(int, int)
|
accept genericParamOnce(int, int)
|
||||||
accept genericParamOnce(TFoo, TFoo)
|
accept genericParamOnce(TFoo, TFoo)
|
||||||
|
|
@ -68,8 +66,7 @@ reject typePairs2(string, int, TBAR, TBAR)
|
||||||
|
|
||||||
proc dontBind(a: typedesc, b: typedesc) =
|
proc dontBind(a: typedesc, b: typedesc) =
|
||||||
static:
|
static:
|
||||||
echo a.name
|
echo a.name, " ", b.name
|
||||||
echo b.name
|
|
||||||
|
|
||||||
accept dontBind(int, float)
|
accept dontBind(int, float)
|
||||||
accept dontBind(TFoo, TFoo)
|
accept dontBind(TFoo, TFoo)
|
||||||
|
|
|
||||||
1
tests/threads/nimrod.cfg
Normal file
1
tests/threads/nimrod.cfg
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
threads:on
|
||||||
Loading…
Add table
Add a link
Reference in a new issue