parent
fc37554795
commit
354eb2a86c
2 changed files with 14 additions and 3 deletions
|
|
@ -593,9 +593,12 @@ proc msgSymChoiceUseQualifier(c: PContext; n: PNode; note = errGenerated) =
|
||||||
|
|
||||||
template isLocalVarSym(n: PNode): bool =
|
template isLocalVarSym(n: PNode): bool =
|
||||||
n.kind == nkSym and
|
n.kind == nkSym and
|
||||||
n.sym.kind in {skVar, skLet} and not
|
(n.sym.kind in {skVar, skLet} and not
|
||||||
({sfGlobal, sfPure} <= n.sym.flags or
|
({sfGlobal, sfPure} <= n.sym.flags or
|
||||||
sfCompileTime in n.sym.flags)
|
sfCompileTime in n.sym.flags) or
|
||||||
|
n.sym.kind in {skProc, skFunc, skIterator} and
|
||||||
|
sfGlobal notin n.sym.flags
|
||||||
|
)
|
||||||
|
|
||||||
proc usesLocalVar(n: PNode): bool =
|
proc usesLocalVar(n: PNode): bool =
|
||||||
for z in 1 ..< n.len:
|
for z in 1 ..< n.len:
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ action: "reject"
|
||||||
nimout: '''
|
nimout: '''
|
||||||
t3505.nim(22, 22) Error: cannot assign local to global variable
|
t3505.nim(22, 22) Error: cannot assign local to global variable
|
||||||
t3505.nim(31, 28) Error: cannot assign local to global variable
|
t3505.nim(31, 28) Error: cannot assign local to global variable
|
||||||
|
t3505.nim(39, 29) Error: cannot assign local to global variable
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -31,3 +31,11 @@ proc main() =
|
||||||
var x {.global.} = initX2(initX(f))
|
var x {.global.} = initX2(initX(f))
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
# issue #20866
|
||||||
|
proc foo2() =
|
||||||
|
iterator bar() {.closure.} =
|
||||||
|
discard
|
||||||
|
var g {.global.} = rawProc(bar)
|
||||||
|
|
||||||
|
foo2()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue