fixes #2594
This commit is contained in:
parent
c921f30b1d
commit
fd80a51547
3 changed files with 26 additions and 3 deletions
|
|
@ -986,8 +986,11 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode,
|
||||||
if r.sym == nil or sfAnon notin r.sym.flags:
|
if r.sym == nil or sfAnon notin r.sym.flags:
|
||||||
let lifted = liftParamType(c, kind, genericParams, r, "result",
|
let lifted = liftParamType(c, kind, genericParams, r, "result",
|
||||||
n.sons[0].info)
|
n.sons[0].info)
|
||||||
if lifted != nil: r = lifted
|
if lifted != nil:
|
||||||
r.flags.incl tfRetType
|
r = lifted
|
||||||
|
#if r.kind != tyGenericParam:
|
||||||
|
#echo "came here for ", typeToString(r)
|
||||||
|
r.flags.incl tfRetType
|
||||||
r = skipIntLit(r)
|
r = skipIntLit(r)
|
||||||
if kind == skIterator:
|
if kind == skIterator:
|
||||||
# see tchainediterators
|
# see tchainediterators
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
proc myFun[A,B](x: A): B =
|
proc myFun[A](x: A): auto =
|
||||||
result = float(x+10)
|
result = float(x+10)
|
||||||
|
|
||||||
proc myMap[T,S](sIn: seq[T], f: proc (q: T): S): seq[S] =
|
proc myMap[T,S](sIn: seq[T], f: proc (q: T): S): seq[S] =
|
||||||
|
|
|
||||||
20
tests/metatype/tunresolved_return_type.nim
Normal file
20
tests/metatype/tunresolved_return_type.nim
Normal 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)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue