mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
fixes #2594
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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] =
|
||||
|
||||
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)
|
||||
Reference in New Issue
Block a user