summary refs log tree commit diff stats
path: root/tests/parser/tprecedence.nim
blob: 66a2922dbd7e7e5f1be810857dcb1aef1b8c3a12 (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
discard """
  output: '''holla
true
defabc 4
0'''
"""

# Test top level semicolon works properly:
import os; echo "holla"

# Test the new predence rules

proc `\+` (x, y: int): int = result = x + y
proc `\*` (x, y: int): int = result = x * y

echo 5 \+ 1 \* 9 == 6*9

proc foo[S, T](x: S, y: T): T = x & y

proc bar[T](x: T): T = x

echo "def".foo[:string, string]("abc"), " ", 4.bar[:int]

# bug #9574
proc isFalse(a: int): bool = false

assert not isFalse(3)

# bug #9633

type
  MyField = object
    b: seq[string]

  MyObject = object
    f: MyField

proc getX(x: MyObject): lent MyField {.inline.} =
  x.f

let a = MyObject()
echo a.getX.b.len


# bug  #10458
template t(x: untyped): untyped = "x"

let
  aaa = t 2 + 4
  ccc = t (1, 1) + 6
  ddd = t [0, 1, 2] + 5

# bug #10896
const
  test =
    proc(): int = 1