1
2
3
4
5
6
7 :(scenario can_modify_ingredients_that_are_also_products)
8
9 def main [
10 local-scope
11 p:point <- merge 34, 35
12 p <- foo p
13 ]
14 def foo p:point -> p:point [
15 local-scope
16 load-ingredients
17 p <- put p, x:offset, 34
18 ]
19 $error: 0
20
21 :(scenario can_modify_ingredients_that_are_also_products_2)
22 def main [
23 local-scope
24 p:&:point <- new point:type
25 p <- foo p
26 ]
27
28 def foo p:&:point -> p:&:point [
29 local-scope
30 load-ingredients
31 *p <- put *p, x:offset, 34
32 ]
33 $error: 0
34
35 :(scenario can_modify_ingredients_that_are_also_products_3)
36 def main [
37 local-scope
38 p:&:@:num <- new number:type, 3
39 p <- foo p
40 ]
41
42 def foo p:&:@:num -> p:&:@:num [
43 local-scope
44 load-ingredients
45 *p <- put-index *p, 0, 34
46 ]
47 $error: 0
48
49 :(scenario ignore_literal_ingredients_for_immutability_checks)
50 def main [
51 local-scope
52 p:&:d1 <- new d1:type
53 q:num <- foo p
54 ]
55 def foo p:&:d1 -> q:num [
56 local-scope
57 load-ingredients
58 x:&:d1 <- new d1:type
59 *x <- put *x, p:offset, 34
60 return 36
61 ]
62 container d1 [
63 p:num
64 q:num
65 ]
66 $error: 0
67
68 :(scenario cannot_modify_immutable_ingredients)
69 % Hide_errors = true;
70 def main [
71 local-scope
72 x:&:num <- new number:type
73 foo x
74 ]
75
76 def foo x:&:num [
77 local-scope
78 load-ingredients
79 *x <- copy 34
80 ]
81 +error: foo: cannot modify 'x' in instruction '*x <- copy 34' because it's an ingredient of recipe foo but not also a product
82
83 :(scenario cannot_modify_immutable_containers)
84 % Hide_errors = true;
85 def main [
86 local-scope
87 x:point-number <- merge 34, 35, 36
88 foo x
89 ]
90
91 def foo x:point-number [
92 local-scope
93 load-ingredients
94
95 y:point <- get x, xy:offset
96
97
98
99 y <- put y, x:offset, 37
100 ]
101 +error: foo: cannot modify 'y' in instruction 'y <- put y, x:offset, 37' because that would modify 'x' which is an ingredient of recipe foo but not also a product
102
103 :(scenario can_modify_immutable_pointers)
104 def main [
105 local-scope
106 x:&:num <- new number:type
107 foo x
108 ]
109 def foo x:&:num [
110 local-scope
111 load-ingredients
112
113 x <- copy null
114 ]
115 $error: 0
116
117 :(scenario can_modify_immutable_pointers_but_not_their_payloads)
118 % Hide_errors = true;
119 def main [
120 local-scope
121 x:&:num <- new number:type
122 foo x
123 ]
124 def foo x:&:num [
125 local-scope
126 load-ingredients
127
128 x <- new number:type
129
130
131 *x <- copy 34
132 ]
133 +error: foo: cannot modify 'x' in instruction '*x <- copy 34' because it's an ingredient of recipe foo but not also a product
134
135 :(scenario cannot_call_mutating_recipes_on_immutable_ingredients)
136 % Hide_errors = true;
137 def main [
138 local-scope
139 p:&:point <- new point:type
140 foo p
141 ]
142 def foo p:&:point [
143 local-scope
144 load-ingredients
145 bar p
146 ]
147 def bar p:&:point -> p:&:point [
148 local-scope
149 load-ingredients
150
151
152 ]
153 +error: foo: cannot modify 'p' in instruction 'bar p' because it's an ingredient of recipe foo but not also a product
154
155 :(scenario cannot_modify_copies_of_immutable_ingredients)
156 % Hide_errors = true;
157 def main [
158 local-scope
159 p:&:point <- new point:type
160 foo p
161 ]
162 def foo p:&:point [
163 local-scope
164 load-ingredients
165 q:&:point <- copy p
166 *q <- put *q, x:offset, 34
167 ]
168 +error: foo: cannot modify 'q' in instruction '*q <- put *q, x:offset, 34' because that would modify p which is an ingredient of recipe foo but not also a product
169
170 :(scenario can_modify_copies_of_mutable_ingredients)
171 def main [
172 local-scope
173 p:&:point <- new point:type
174 foo p
175 ]
176 def foo p:&:point -> p:&:point [
177 local-scope
178 load-ingredients
179 q:&:point <- copy p
180 *q <- put *q, x:offset, 34
181 ]
182 $error: 0
183
184 :(scenario cannot_modify_address_inside_immutable_ingredients)
185 % Hide_errors = true;
186 container foo [
187 x:&:@:num
188 ]
189 def main [
190
191 ]
192 def foo a:&:foo [
193 local-scope
194 load-ingredients
195 x:&:@:num <- get *a, x:offset
196 *x <- put-index *x, 0, 34
197 ]
198 +error: foo: cannot modify 'x' in instruction '*x <- put-index *x, 0, 34' because that would modify a which is an ingredient of recipe foo but not also a product
199
200 :(scenario cannot_modify_address_inside_immutable_ingredients_2)
201 container foo [
202 x:&:@:num
203 ]
204 def main [
205
206 ]
207 def foo a:&:foo [
208 local-scope
209 load-ingredients
210 b:foo <- merge null
211
212 x:&:@:num <- get b, x:offset
213 *x <- put-index *x, 0, 34
214 ]
215 $error: 0
216
217 :(scenario cannot_modify_address_inside_immutable_ingredients_3)
218 % Hide_errors = true;
219 def main [
220
221 ]
222 def foo a:&:@:&:num [
223 local-scope
224 load-ingredients
225 x:&:num <- index *a, 0
226 *x <- copy 34
227 ]
228 +error: foo: cannot modify 'x' in instruction '*x <- copy 34' because that would modify a which is an ingredient of recipe foo but not also a product
229
230 :(scenario cannot_modify_address_inside_immutable_ingredients_4)
231 def main [
232
233 ]
234 def foo a:&:@:&:num [
235 local-scope
236 load-ingredients
237 b:&:@:&:num <- new {(address number): type}, 3
238
239 x:&:num <- index *b, 0
240 *x <- copy 34
241 ]
242 $error: 0
243
244 :(scenario latter_ingredient_of_index_is_immutable)
245 def main [
246
247 ]
248 def foo a:&:@:&:@:num, b:num -> a:&:@:&:@:num [
249 <