Fix compileTime pragma applying to whole var/let section (#10389)
This commit is contained in:
parent
44c04b3571
commit
226c15499f
2 changed files with 19 additions and 6 deletions
|
|
@ -432,7 +432,6 @@ proc setVarType(c: PContext; v: PSym, typ: PType) =
|
||||||
proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
|
proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
|
||||||
var b: PNode
|
var b: PNode
|
||||||
result = copyNode(n)
|
result = copyNode(n)
|
||||||
var hasCompileTime = false
|
|
||||||
for i in countup(0, sonsLen(n)-1):
|
for i in countup(0, sonsLen(n)-1):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
if c.config.cmd == cmdIdeTools: suggestStmt(c, a)
|
if c.config.cmd == cmdIdeTools: suggestStmt(c, a)
|
||||||
|
|
@ -556,13 +555,12 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
|
||||||
else: v.typ = tup
|
else: v.typ = tup
|
||||||
b.sons[j] = newSymNode(v)
|
b.sons[j] = newSymNode(v)
|
||||||
checkNilable(c, v)
|
checkNilable(c, v)
|
||||||
if sfCompileTime in v.flags: hasCompileTime = true
|
if sfCompileTime in v.flags:
|
||||||
|
var x = newNodeI(result.kind, v.info)
|
||||||
|
addSon(x, result[i])
|
||||||
|
vm.setupCompileTimeVar(c.module, c.graph, x)
|
||||||
if v.flags * {sfGlobal, sfThread} == {sfGlobal}:
|
if v.flags * {sfGlobal, sfThread} == {sfGlobal}:
|
||||||
message(c.config, v.info, hintGlobalVar)
|
message(c.config, v.info, hintGlobalVar)
|
||||||
if hasCompileTime:
|
|
||||||
vm.setupCompileTimeVar(c.module, c.graph, result)
|
|
||||||
# handled by the VM codegen:
|
|
||||||
#c.graph.recordStmt(c.graph, c.module, result)
|
|
||||||
|
|
||||||
proc semConst(c: PContext, n: PNode): PNode =
|
proc semConst(c: PContext, n: PNode): PNode =
|
||||||
result = copyNode(n)
|
result = copyNode(n)
|
||||||
|
|
|
||||||
15
tests/vm/tvarsection.nim
Normal file
15
tests/vm/tvarsection.nim
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
discard """
|
||||||
|
output: '''-1abc'''
|
||||||
|
"""
|
||||||
|
|
||||||
|
var
|
||||||
|
a {.compileTime.} = 2
|
||||||
|
b = -1
|
||||||
|
c {.compileTime.} = 3
|
||||||
|
d = "abc"
|
||||||
|
|
||||||
|
static:
|
||||||
|
assert a == 2
|
||||||
|
assert c == 3
|
||||||
|
|
||||||
|
echo b, d
|
||||||
Loading…
Add table
Add a link
Reference in a new issue