mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-21 12:00:44 +00:00
fixes #3066
This commit is contained in:
@@ -1184,6 +1184,9 @@ proc checkCanEval(c: PCtx; n: PNode) =
|
||||
if s.kind in {skVar, skTemp, skLet, skParam, skResult} and
|
||||
not s.isOwnedBy(c.prc.sym) and s.owner != c.module:
|
||||
cannotEval(n)
|
||||
elif s.kind in {skProc, skConverter, skMethod,
|
||||
skIterator, skClosureIterator} and sfForward in s.flags:
|
||||
cannotEval(n)
|
||||
|
||||
proc isTemp(c: PCtx; dest: TDest): bool =
|
||||
result = dest >= 0 and c.prc.slots[dest].kind >= slotTempUnknown
|
||||
|
||||
17
tests/vm/tforwardproc.nim
Normal file
17
tests/vm/tforwardproc.nim
Normal file
@@ -0,0 +1,17 @@
|
||||
discard """
|
||||
errormsg: "cannot evaluate at compile time: initArray"
|
||||
line: 11
|
||||
"""
|
||||
|
||||
# bug #3066
|
||||
|
||||
proc initArray(): array[10, int]
|
||||
|
||||
const
|
||||
someTable = initArray()
|
||||
|
||||
proc initArray(): array[10, int] =
|
||||
for f in 0..<10:
|
||||
result[f] = 3
|
||||
|
||||
when isMainModule: echo repr(someTable)
|
||||
Reference in New Issue
Block a user