diff options
author | Araq <rumpf_a@web.de> | 2015-01-10 22:57:22 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2015-01-10 23:52:29 +0100 |
commit | 8cb31d86b66457e9db848bb3f55f25fe58c4a7da (patch) | |
tree | eae7be4f38811103065f009c4f6a4b59323a547a | |
parent | 3273d32acc0ad9452ccbb9790769806af9721571 (diff) | |
download | Nim-8cb31d86b66457e9db848bb3f55f25fe58c4a7da.tar.gz |
fixes tconfusing_arrow bug
-rw-r--r-- | compiler/semstmts.nim | 4 | ||||
-rw-r--r-- | tests/generics/tconfusing_arrow.nim | 15 |
2 files changed, 18 insertions, 1 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 1396ef374..bdff15926 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -732,7 +732,7 @@ proc semBorrow(c: PContext, n: PNode, s: PSym) = localError(n.info, errNoSymbolToBorrowFromFound) proc addResult(c: PContext, t: PType, info: TLineInfo, owner: TSymKind) = - if t != nil: + if t != nil: var s = newSym(skResult, getIdent"result", getCurrOwner(), info) s.typ = t incl(s.flags, sfUsed) @@ -851,6 +851,7 @@ proc semInferredLambda(c: PContext, pt: TIdTable, n: PNode): PNode = openScope(c) var s = n.sons[namePos].sym + pushOwner(s) addParams(c, n.typ.n, skProc) pushProcCon(c, s) addResult(c, n.typ.sons[0], n.info, skProc) @@ -858,6 +859,7 @@ proc semInferredLambda(c: PContext, pt: TIdTable, n: PNode): PNode = n.sons[bodyPos] = transformBody(c.module, semBody, n.sons[namePos].sym) addResultNode(c, n) popProcCon(c) + popOwner() closeScope(c) s.ast = result diff --git a/tests/generics/tconfusing_arrow.nim b/tests/generics/tconfusing_arrow.nim new file mode 100644 index 000000000..6a5a9d682 --- /dev/null +++ b/tests/generics/tconfusing_arrow.nim @@ -0,0 +1,15 @@ +import algorithm, future + +type Deck = object + value: int + +proc sort(h: var seq[Deck]) = + # works: + h.sort(proc (x, y: Deck): auto = + cmp(x.value, y.value)) + # fails: + h.sort((x, y: Deck) => cmp(ord(x.value), ord(y.value))) + +var player: seq[Deck] = @[] + +player.sort() |