summaryrefslogtreecommitdiff
path: root/tests/typ/compiler/ops-invalid.typ
blob: 8ccbb8b77c0879693602590caee8d20318679d8a (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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// Test invalid operations.
// Ref: false

---
// Error: 4 expected expression
#(-)

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

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

---
// Error: 3-13 cannot apply '+' to content
#(+([] + []))

---
// Error: 3-6 cannot apply '-' to string
#(-"")

---
// Error: 3-9 cannot apply 'not' to array
#(not ())

---
// Error: 3-19 cannot apply '<=' to relative length and ratio
#(30% + 1pt <= 40%)

---
// Error: 3-14 cannot apply '<=' to length and length
#(1em <= 10pt)

---
// Error: 3-12 cannot divide by zero
#(1.2 / 0.0)

---
// Error: 3-8 cannot divide by zero
#(1 / 0)

---
// Error: 3-15 cannot divide by zero
#(15deg / 0deg)

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

---
// Error: 15-23 cannot add integer and string
#{ let x = 1; x += "2" }

---
// Error: 4-13 cannot divide ratio by length
#( 10% / 5pt )

---
// Error: 3-12 cannot divide these two lengths
#(1em / 5pt)

---
// Error: 3-19 cannot divide relative length by ratio
#((10% + 1pt) / 5%)

---
// Error: 3-28 cannot divide these two relative lengths
#((10% + 1pt) / (20% + 1pt))

---
// Error: 13-20 cannot subtract integer from ratio
#((1234567, 40% - 1))

---
// Error: 3-11 cannot multiply integer with boolean
#(2 * true)

---
// Error: 3-11 cannot divide integer by length
#(3 / 12pt)

---
// Error: 3-10 cannot repeat this string -1 times
#(-1 * "")

---
#{
  let x = 2
  for _ in range(61) {
    (x) *= 2
  }
  // Error: 3-17 cannot repeat this string 4611686018427387904 times
  x * "abcdefgh"
}

---
// Error: 4-5 unknown variable
#((x) = "")

---
// Error: 3-8 cannot mutate a temporary value
#(1 + 2 += 3)

---
// Error: 2:3-2:8 cannot apply 'not' to string
#let x = "Hey"
#(not x = "a")

---
// Error: 7-8 unknown variable
#(1 + x += 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")