summaryrefslogtreecommitdiff
path: root/tests/typ/code/ops-invalid.typ
blob: 1355181af8061c1d7a81f57bb1dfab223df73e49 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Test invalid operations.
// Ref: false

---
// Error: 3 expected expression
{-}

---
// Error: 10 expected expression
#test({1+}, 1)

---
// Error: 10 expected expression
#test({2*}, 2)

---
// Error: 2-12 cannot apply '+' to template
{+([] + [])}

---
// Error: 2-5 cannot apply '-' to string
{-""}

---
// Error: 2-8 cannot apply 'not' to array
{not ()}

---
// Error: 2-18 cannot apply '<=' to linear and relative
{30% + 1pt <= 40%}

---
// Special messages for +, -, * and /.
// Error: 03-10 cannot add integer and string
{(1 + "2", 40% - 1)}

---
// Error: 12-19 cannot subtract integer from relative
{(1234567, 40% - 1)}

---
// Error: 2-10 cannot multiply integer with boolean
{2 * true}

---
// Error: 2-10 cannot divide integer by length
{3 / 12pt}

---
// Error: 2-9 cannot repeat this string -1 times
{-1 * ""}

---
{
  let x = 2
  for _ in 0..61 {
    x *= 2
  }
  // Error: 4-18 cannot repeat this string 4611686018427387904 times
  {x * "abcdefgh"}
}

---
// Error: 14-22 cannot add integer and string
{ let x = 1; x += "2" }

---
// Error: 13-14 expected argument list, found integer
{ test with 2 }

---
// Error: 3-4 expected function, found integer
{ 1 with () }

---
// Error: 3-10 cannot apply '..' to integer and string
{ 1 .. "" }

---
// Error: 3-6 cannot access this expression mutably
{ (x) = "" }

---
// Error: 3-8 cannot access this expression mutably
{ 1 + 2 += 3 }

---
// Error: 3-4 unknown variable
{ z = 1 }

---
// Error: 3-7 cannot mutate a constant
{ rect = "hi" }

---
// Works if we define rect beforehand
// (since then it doesn't resolve to the standard library version anymore).
#let rect = ""
{ rect = "hi" }