forked from vectorgraphics/asymptote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errortest.asy
514 lines (491 loc) · 6.75 KB
/
errortest.asy
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
/*****
* errortest.asy
* Andy Hammerlindl 2003/08/08
*
* This struct attempts to trigger every error message reportable by the
* compiler to ensure that errors are being reported properly.
*****/
// name.cc
{
// line 33
x.y = 5;
}
{
// line 50
int x = z;
}
{
// line 67
x = 5;
}
{
// line 84 - unreachable
}
{
// line 95
x y1;
x y2();
x y3(int);
int y4(x);
struct m {
x y1;
x y2();
x y3(int);
int y4(x);
}
}
{
// line 130
int x;
x.y = 4;
}
{
// line 156
struct m {
int x,y;
}
m.u.v = 5;
}
{
// line 186
struct m {
int x,y;
}
int x = m.z;
}
{
// line 217
struct m {
int x,y;
}
m.z = 5;
}
{
// line 249 - unreachable
}
{
// line 272 - not testable without typedef
}
{
// line 283
struct m {
int x,y;
}
m.u v;
struct mm {
m.u v;
}
}
// exp.h
{
// line 109
5 = 4;
}
{
// line 136
int f, f();
f;
struct m { int f, f(); }
m.f;
}
// exp.cc
{
// line 40
int x = {};
int y = {4, 5, 6};
}
{
// line 110
int f(), f(int);
f.m = 5;
}
{
// line 122
int x;
x.m = 5;
}
{
// line 147
struct point {
int x,y;
}
point p;
int x = p.z;
}
{
// line 157
struct point {
int x, y;
}
point p;
p.z;
}
{
// line 163
struct point {
int f(), f(int);
}
point p;
p.f;
}
{
// line 204
struct point {
int x, y;
}
point p;
p.z = 5;
}
{
// line 229 - unreachable
}
{
// lines 261 and 275 - wait for subscript to be fully implemented.
}
{
// line 515
void f(int), f(int, int);
f();
f("Hello?");
}
{
// line 520 - not yet testable (need int->float casting or the like)
}
{
// line 525
void f(int);
f();
}
{
// line 649
struct point {
int x,y;
}
point p;
p = +p;
}
{
// line 1359
int x, f();
(true) ? x : f;
}
{
// line 1359
int a, a(), b, b();
(true) ? a : b;
}
{
// line 1581
int x, f();
x = f;
}
{
// line 1586
int a, a(), b, b();
a = b;
}
// newexp.cc
{
// line 34
int f() = new int () {
int x = 5;
};
}
{
// line 64
int x = new int;
}
{
// line 72
struct a {
struct b {
}
}
new a.b;
}
// stm.cc
{
// line 86
5;
}
{
// line 246
break;
}
{
// line 261
continue;
}
{
// line 282
void f() {
return 17;
}
}
{
// line 288
int f() {
return;
}
}
// dec.cc
{
// line 378
int f() {
int x = 5;
}
int g() {
if (true)
return 7;
}
}
// env.h
{
// line 99
struct m {}
struct m {}
}
{
// line 109
int f() {
return 1;
}
int f() {
return 2;
}
int x = 1;
int x = 2;
struct m {
int f() {
return 1;
}
int f() {
return 2;
}
int x = 1;
int x = 2;
}
}
// env.cc
{
// line 107 - currently unreachable as no built-ins are currently used
// in records.
}
{
// line 140
// Assuming there is a built-in function void abort(string):
void f(string);
abort = f;
}
{
// line 168 - currently unreachable as no built-in functions are
// currently used in records.
}
{
// line 222
int x = "Hello";
}
// Test permissions.
{
struct A {
private int x=4;
restricted int y=5;
private void f() {}
restricted void g() {}
}
A a;
a.x;
a.x = 4;
a.x += 5;
a.y = 6;
a.y += 7;
a.f;
a.f();
a.f = new void() {};
a.g = new void() {};
}
{
struct A {
private int x=4;
private void f() {}
}
A a;
from a unravel x;
from a unravel f;
}
{
struct A {
restricted int y=5;
restricted void g() {}
}
A a;
from a unravel y,g;
y = 6;
y += 7;
g = new void() {};
}
{
struct A {
private typedef int T;
}
A.T x;
A.T x=4;
int y=2;
A.T x=y;
A.T x=17+3*y;
}
{
struct A {
private typedef int T;
}
from A unravel T;
}
{
struct A {
private typedef int T;
}
A a;
a.T x;
a.T x=4;
int y=2;
a.T x=y;
a.T x=17+3*y;
}
{
struct A {
private typedef int T;
}
A a;
from a unravel T;
}
// Read-only settings
// Ensure that the safe and globalwrite options can't be modified inside the
// code.
{
access settings;
settings.safe=false;
settings.safe=true;
settings.globalwrite=false;
settings.globalwrite=true;
}
{
from settings access safe, globalwrite;
safe=false;
safe=true;
globalwrite=false;
globalwrite=true;
}
{
from settings access safe as x, globalwrite as y;
x=false;
x=true;
y=false;
y=true;
}
{
import settings;
settings.safe=false;
settings.safe=true;
settings.globalwrite=false;
settings.globalwrite=true;
safe=false;
safe=true;
globalwrite=false;
globalwrite=true;
}
// Test cases where var is used outside of type inference.
{
var x;
}
{
var f() { return 4; }
}
{
(var)3;
var x = (var)3;
int y = (var)3;
}
{
var[] b = new var[] { 1, 2, 3};
var[] b = new int[] { 1, 2, 3};
var[] c = {1, 2, 3};
new var[] { 4, 5, 6};
int[] d = new var[] { 4, 5, 6};
new var;
}
{
int f(var x = 3) { return 0; }
}
{
int f, f();
var g = f;
}
{
struct A { int f, f(); }
var g = A.f;
A a;
var h = a.f;
}
{
int x;
for (var i : x)
;
}
{
int x, x();
for (var i : x)
;
}
{
int x, x();
int[] x = {2,3,4};
for (var i : x)
;
}
{
int[] temp={0};
int[] v={0};
temp[v]= v;
}
// Keyword and rest errors.
{
int f(string s="" ... int[] a);
f(1,2,3 ... new int[] {4,5,6}, "hi");
f(1,2,3 ... new int[] {4,5,6} ... new int[] {7,8,9});
f(... new int[] {4,5,6}, "hi");
f(... new int[] {4,5,6} ... new int[] {7,8,9});
}
{
int f(... int[] x, int y);
int g(... int[] x, int y) { return 7; }
int f(string s ... int[] x, int y);
int g(string s ... int[] x, int y) { return 7; }
int f(int keyword x, int y);
int g(int keyword x, int y) { return 7; }
int f(int keyword x, int y, string z);
int g(int keyword x, int y, string z) { return 7; }
int f(real t, int keyword x, int y);
int g(real t, int keyword x, int y) { return 7; }
int f(real t, int keyword x, int y, string z);
int g(real t, int keyword x, int y, string z) { return 7; }
}
{
int f(int notkeyword x);
int g(int notkeyword x) { return 7; }
int f(real w, int notkeyword x);
int g(real w, int notkeyword x) { return 7; }
int f(real w, int keyword y, int notkeyword x);
int g(real w, int keyword y, int notkeyword x) { return 7; }
int f(real w, int notkeyword y, int keyword x);
int g(real w, int notkeyword y, int keyword x) { return 7; }
int f(int notkeyword x, int y, string z);
int g(int notkeyword x, int y, string z) { return 7; }
int f(int notkeyword x, int y);
int g(int notkeyword x, int y) { return 7; }
int f(int notkeyword x, int y, string z);
int g(int notkeyword x, int y, string z) { return 7; }
int f(real t, int notkeyword x, int y);
int g(real t, int notkeyword x, int y) { return 7; }
int f(real t, int notkeyword x, int y, string z);
int g(real t, int notkeyword x, int y, string z) { return 7; }
}