summary refs log tree commit diff stats
path: root/tests/global/t3505.nim
blob: 437a02ae6953607836faad331ed03cc4ab4e2918 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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()