This commit is contained in:
Araq
2015-09-18 12:07:39 +02:00
parent c921f30b1d
commit fd80a51547
3 changed files with 26 additions and 3 deletions

View File

@@ -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

View File

@@ -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] =

View File

@@ -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)