summary refs log tree commit diff stats
path: root/tests/parser/tletcolon.nim
blob: a2dde148aa78f1780cb247fafa3c251cbef1ff40 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
discard """
  output: '''boo
3
44 3
more body code
yes
yes
block expression works'''
"""

template x(body): untyped =
  body
  44

template y(val, body): untyped =
  body
  val

proc mana =
  let foo = x:
    echo "boo"
  var foo2: int
  foo2 = y 3:
    echo "3"
  echo foo, " ", foo2

mana()
let other = x:
  echo "more body code"
  if true:
    echo "yes"
  else:
    echo "no"
let outer = y(5):
  echo "yes"


# bug #6609
type
  TextureInternalFormat = enum RED, RGB, RGBA

const channels = 4

let format =
    if channels == 1:
        TextureInternalFormat.RED
    elif channels == 3:
        TextureInternalFormat.RGB
    elif channels == 4:
        TextureInternalFormat.RGBA
    else:
        echo "Texture Format Unknown, assuming RGB"  #This echo causes an error
        TextureInternalFormat.RGB

# Block as expressions #3827
block:
  let x = block:
    var y = 2
    echo "block expression works"
    y*y
  doAssert x == 4


# bug 10861
macro foo(a: untyped): untyped = 
  a             

let c1 = foo:
  1 + 1

const c2 = foo:
  1 + 1

const c3 = 
  foo: 1 + 1