diff options
Diffstat (limited to 'tests/global/t3505.nim')
-rw-r--r-- | tests/global/t3505.nim | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/global/t3505.nim b/tests/global/t3505.nim new file mode 100644 index 000000000..437a02ae6 --- /dev/null +++ b/tests/global/t3505.nim @@ -0,0 +1,41 @@ +discard """ +cmd: "nim check $options --hints:off $file" +action: "reject" +nimout: ''' +t3505.nim(22, 22) 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 + + + + +''' +""" + + + + + + +proc foo = + let a = 0 + var b {.global.} = a +foo() + +# issue #5132 +proc initX(it: float): int = 8 +proc initX2(it: int): int = it + +proc main() = + var f: float + var x {.global.} = initX2(initX(f)) + +main() + +# issue #20866 +proc foo2() = + iterator bar() {.closure.} = + discard + var g {.global.} = rawProc(bar) + +foo2() \ No newline at end of file |