parent
45759b5e90
commit
cc2be5e4c6
2 changed files with 26 additions and 4 deletions
|
|
@ -709,13 +709,17 @@ proc evalAtCompileTime(c: PContext, n: PNode): PNode =
|
||||||
n.typ.flags.incl tfUnresolved
|
n.typ.flags.incl tfUnresolved
|
||||||
|
|
||||||
# optimization pass: not necessary for correctness of the semantic pass
|
# optimization pass: not necessary for correctness of the semantic pass
|
||||||
if {sfNoSideEffect, sfCompileTime} * callee.flags != {} and
|
if callee.kind == skConst or
|
||||||
|
{sfNoSideEffect, sfCompileTime} * callee.flags != {} and
|
||||||
{sfForward, sfImportc} * callee.flags == {} and n.typ != nil:
|
{sfForward, sfImportc} * callee.flags == {} and n.typ != nil:
|
||||||
if sfCompileTime notin callee.flags and
|
|
||||||
optImplicitStatic notin c.config.options: return
|
if callee.kind != skConst and
|
||||||
|
sfCompileTime notin callee.flags and
|
||||||
|
optImplicitStatic notin c.config.options: return
|
||||||
|
|
||||||
if callee.magic notin ctfeWhitelist: return
|
if callee.magic notin ctfeWhitelist: return
|
||||||
if callee.kind notin {skProc, skFunc, skConverter} or callee.isGenericRoutine:
|
|
||||||
|
if callee.kind notin {skProc, skFunc, skConverter, skConst} or callee.isGenericRoutine:
|
||||||
return
|
return
|
||||||
|
|
||||||
if n.typ != nil and typeAllowed(n.typ, skConst) != nil: return
|
if n.typ != nil and typeAllowed(n.typ, skConst) != nil: return
|
||||||
|
|
|
||||||
18
tests/vm/tconstprocassignments.nim
Normal file
18
tests/vm/tconstprocassignments.nim
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
discard """
|
||||||
|
output: '''
|
||||||
|
100
|
||||||
|
100
|
||||||
|
'''
|
||||||
|
"""
|
||||||
|
|
||||||
|
proc f():int {.compileTime.} = 100
|
||||||
|
|
||||||
|
const F = f
|
||||||
|
echo F()
|
||||||
|
|
||||||
|
const G = proc ():int =
|
||||||
|
let x = f
|
||||||
|
let y = x
|
||||||
|
y()
|
||||||
|
|
||||||
|
echo G()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue