fixes #2073
This commit is contained in:
parent
c91ca82a43
commit
ada0f14711
4 changed files with 20 additions and 4 deletions
|
|
@ -825,9 +825,9 @@ proc semLambda(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
if gp.len == 0 or (gp.len == 1 and tfRetType in gp[0].typ.flags):
|
if gp.len == 0 or (gp.len == 1 and tfRetType in gp[0].typ.flags):
|
||||||
pushProcCon(c, s)
|
pushProcCon(c, s)
|
||||||
addResult(c, s.typ.sons[0], n.info, skProc)
|
addResult(c, s.typ.sons[0], n.info, skProc)
|
||||||
|
addResultNode(c, n)
|
||||||
let semBody = hloBody(c, semProcBody(c, n.sons[bodyPos]))
|
let semBody = hloBody(c, semProcBody(c, n.sons[bodyPos]))
|
||||||
n.sons[bodyPos] = transformBody(c.module, semBody, s)
|
n.sons[bodyPos] = transformBody(c.module, semBody, s)
|
||||||
addResultNode(c, n)
|
|
||||||
popProcCon(c)
|
popProcCon(c)
|
||||||
elif efOperand notin flags:
|
elif efOperand notin flags:
|
||||||
localError(n.info, errGenericLambdaNotAllowed)
|
localError(n.info, errGenericLambdaNotAllowed)
|
||||||
|
|
@ -860,9 +860,9 @@ proc semInferredLambda(c: PContext, pt: TIdTable, n: PNode): PNode =
|
||||||
addParams(c, n.typ.n, skProc)
|
addParams(c, n.typ.n, skProc)
|
||||||
pushProcCon(c, s)
|
pushProcCon(c, s)
|
||||||
addResult(c, n.typ.sons[0], n.info, skProc)
|
addResult(c, n.typ.sons[0], n.info, skProc)
|
||||||
|
addResultNode(c, n)
|
||||||
let semBody = hloBody(c, semProcBody(c, n.sons[bodyPos]))
|
let semBody = hloBody(c, semProcBody(c, n.sons[bodyPos]))
|
||||||
n.sons[bodyPos] = transformBody(c.module, semBody, n.sons[namePos].sym)
|
n.sons[bodyPos] = transformBody(c.module, semBody, n.sons[namePos].sym)
|
||||||
addResultNode(c, n)
|
|
||||||
popProcCon(c)
|
popProcCon(c)
|
||||||
popOwner()
|
popOwner()
|
||||||
closeScope(c)
|
closeScope(c)
|
||||||
|
|
|
||||||
|
|
@ -3161,7 +3161,7 @@ when hostOS != "standalone":
|
||||||
x[j+i] = item[j]
|
x[j+i] = item[j]
|
||||||
inc(j)
|
inc(j)
|
||||||
|
|
||||||
proc compiles*(x): bool {.magic: "Compiles", noSideEffect.} =
|
proc compiles*(x: expr): bool {.magic: "Compiles", noSideEffect.} =
|
||||||
## Special compile-time procedure that checks whether `x` can be compiled
|
## Special compile-time procedure that checks whether `x` can be compiled
|
||||||
## without any semantic error.
|
## without any semantic error.
|
||||||
## This can be used to check whether a type supports some operation:
|
## This can be used to check whether a type supports some operation:
|
||||||
|
|
|
||||||
15
tests/closure/ttimeinfo.nim
Normal file
15
tests/closure/ttimeinfo.nim
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
# bug #2073
|
||||||
|
|
||||||
|
import sequtils
|
||||||
|
import times
|
||||||
|
|
||||||
|
# 1
|
||||||
|
proc f(n: int): TimeInfo =
|
||||||
|
TimeInfo(year: n, month: mJan, monthday: 1)
|
||||||
|
|
||||||
|
echo toSeq(2000 || 2015).map(f)
|
||||||
|
|
||||||
|
# 2
|
||||||
|
echo toSeq(2000 || 2015).map(proc (n: int): TimeInfo =
|
||||||
|
TimeInfo(year: n, month: mJan, monthday: 1)
|
||||||
|
)
|
||||||
|
|
@ -21,7 +21,8 @@ News
|
||||||
should be used instead.
|
should be used instead.
|
||||||
- ``nim idetools`` has been replaced by a separate tool `nimsuggest`_.
|
- ``nim idetools`` has been replaced by a separate tool `nimsuggest`_.
|
||||||
- *arrow like* operators are not right associative anymore.
|
- *arrow like* operators are not right associative anymore.
|
||||||
|
- Typeless parameters are now only allowed in templates and macros. The old
|
||||||
|
way turned out to be too error-prone.
|
||||||
|
|
||||||
Language Additions
|
Language Additions
|
||||||
------------------
|
------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue