diff options
author | Araq <rumpf_a@web.de> | 2015-09-18 12:07:39 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2015-09-18 12:07:39 +0200 |
commit | fd80a51547f53d10ec96d4e1cb53a7e2ec713807 (patch) | |
tree | 09ad49cbfa559f630ffd728864baa8627cf4627d | |
parent | c921f30b1d575b3e457cc98cb95198d1513e69ab (diff) | |
download | Nim-fd80a51547f53d10ec96d4e1cb53a7e2ec713807.tar.gz |
fixes #2594
-rw-r--r-- | compiler/semtypes.nim | 7 | ||||
-rw-r--r-- | tests/metatype/tprocbothmeta.nim | 2 | ||||
-rw-r--r-- | tests/metatype/tunresolved_return_type.nim | 20 |
3 files changed, 26 insertions, 3 deletions
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index 1cfbc368b..65cb9421b 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -986,8 +986,11 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode, if r.sym == nil or sfAnon notin r.sym.flags: let lifted = liftParamType(c, kind, genericParams, r, "result", n.sons[0].info) - if lifted != nil: r = lifted - r.flags.incl tfRetType + if lifted != nil: + r = lifted + #if r.kind != tyGenericParam: + #echo "came here for ", typeToString(r) + r.flags.incl tfRetType r = skipIntLit(r) if kind == skIterator: # see tchainediterators diff --git a/tests/metatype/tprocbothmeta.nim b/tests/metatype/tprocbothmeta.nim index ad12c5d26..ba061dda2 100644 --- a/tests/metatype/tprocbothmeta.nim +++ b/tests/metatype/tprocbothmeta.nim @@ -1,5 +1,5 @@ -proc myFun[A,B](x: A): B = +proc myFun[A](x: A): auto = result = float(x+10) proc myMap[T,S](sIn: seq[T], f: proc (q: T): S): seq[S] = diff --git a/tests/metatype/tunresolved_return_type.nim b/tests/metatype/tunresolved_return_type.nim new file mode 100644 index 000000000..f67e065ea --- /dev/null +++ b/tests/metatype/tunresolved_return_type.nim @@ -0,0 +1,20 @@ +discard """ + errormsg: "cannot instantiate: 'T'" + line: 12 +""" + +# bug #2594 + + +type + ResultValue* = int64 + +proc toNumber[T: int|uint|int64|uint64](v: ResultValue): T = + if v < low(T) or v > high(T): + raise newException(RangeError, "protocol error") + return T(v) + +#proc toNumber[T](v: int32): T = +# return (v) + +echo toNumber(23) |