mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-12 22:33:49 +00:00
For memory-safety, this only seems problematic in case of closures, so I just special cased that. Fixes #25131
18 lines
221 B
Nim
18 lines
221 B
Nim
discard """
|
|
errormsg: "cannot assign local to global variable"
|
|
line: 14
|
|
"""
|
|
|
|
type X = object
|
|
p: proc() {.closure.}
|
|
|
|
proc main() =
|
|
var x = "hi"
|
|
proc p() =
|
|
echo x
|
|
|
|
let a {.global.} = X(p: p)
|
|
a.p()
|
|
|
|
main()
|