| ... | ... | @@ -49,16 +49,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 49 | 49 | \\const Foo = struct { |
| 50 | 50 | \\ a: undefined, |
| 51 | 51 | \\}; |
| 52 | | \\const Bar = union { |
| 53 | | \\ a: undefined, |
| 54 | | \\}; |
| 55 | | \\pub fn main() void { |
| 52 | \\export fn entry1() void { |
| 56 | 53 | \\ const foo: Foo = undefined; |
| 57 | | \\ const bar: Bar = undefined; |
| 58 | 54 | \\} |
| 59 | 55 | , |
| 60 | 56 | "tmp.zig:2:8: error: expected type 'type', found '(undefined)'", |
| 61 | | "tmp.zig:5:8: error: expected type 'type', found '(undefined)'", |
| 62 | 57 | ); |
| 63 | 58 | |
| 64 | 59 | cases.add( |
| ... | ... | @@ -461,13 +456,25 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 461 | 456 | \\const G = packed struct { |
| 462 | 457 | \\ x: Enum, |
| 463 | 458 | \\}; |
| 464 | | \\export fn entry() void { |
| 459 | \\export fn entry1() void { |
| 465 | 460 | \\ var a: A = undefined; |
| 461 | \\} |
| 462 | \\export fn entry2() void { |
| 466 | 463 | \\ var b: B = undefined; |
| 464 | \\} |
| 465 | \\export fn entry3() void { |
| 467 | 466 | \\ var r: C = undefined; |
| 467 | \\} |
| 468 | \\export fn entry4() void { |
| 468 | 469 | \\ var d: D = undefined; |
| 470 | \\} |
| 471 | \\export fn entry5() void { |
| 469 | 472 | \\ var e: E = undefined; |
| 473 | \\} |
| 474 | \\export fn entry6() void { |
| 470 | 475 | \\ var f: F = undefined; |
| 476 | \\} |
| 477 | \\export fn entry7() void { |
| 471 | 478 | \\ var g: G = undefined; |
| 472 | 479 | \\} |
| 473 | 480 | \\const S = struct { |
| ... | ... | @@ -489,7 +496,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 489 | 496 | "tmp.zig:14:5: error: non-packed, non-extern struct 'U' not allowed in packed struct; no guaranteed in-memory representation", |
| 490 | 497 | "tmp.zig:17:5: error: type '?anyerror' not allowed in packed struct; no guaranteed in-memory representation", |
| 491 | 498 | "tmp.zig:20:5: error: type 'Enum' not allowed in packed struct; no guaranteed in-memory representation", |
| 492 | | "tmp.zig:38:14: note: enum declaration does not specify an integer tag type", |
| 499 | "tmp.zig:50:14: note: enum declaration does not specify an integer tag type", |
| 493 | 500 | ); |
| 494 | 501 | |
| 495 | 502 | cases.addCase(x: { |
| ... | ... | @@ -721,7 +728,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 721 | 728 | \\ var oops = @bitCast(u7, byte); |
| 722 | 729 | \\} |
| 723 | 730 | , |
| 724 | | "tmp.zig:2:16: error: destination type 'u7' has 7 bits but source type 'u8' has 8 bits", |
| 731 | "tmp.zig:2:25: error: destination type 'u7' has 7 bits but source type 'u8' has 8 bits", |
| 725 | 732 | ); |
| 726 | 733 | |
| 727 | 734 | cases.add( |
| ... | ... | @@ -1381,7 +1388,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 1381 | 1388 | \\ for (xx) |f| {} |
| 1382 | 1389 | \\} |
| 1383 | 1390 | , |
| 1384 | | "tmp.zig:7:15: error: variable of type 'Foo' must be const or comptime", |
| 1391 | "tmp.zig:7:5: error: values of type 'Foo' must be comptime known, but index value is runtime known", |
| 1385 | 1392 | ); |
| 1386 | 1393 | |
| 1387 | 1394 | cases.add( |
| ... | ... | @@ -2250,6 +2257,9 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2250 | 2257 | \\} |
| 2251 | 2258 | \\ |
| 2252 | 2259 | \\extern fn bar(x: *void) void { } |
| 2260 | \\export fn entry2() void { |
| 2261 | \\ bar(&{}); |
| 2262 | \\} |
| 2253 | 2263 | , |
| 2254 | 2264 | "tmp.zig:1:30: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'ccc'", |
| 2255 | 2265 | "tmp.zig:7:18: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'ccc'", |
| ... | ... | @@ -2576,7 +2586,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2576 | 2586 | \\ |
| 2577 | 2587 | \\fn b() void {} |
| 2578 | 2588 | , |
| 2579 | | "tmp.zig:3:5: error: unreachable code", |
| 2589 | "tmp.zig:3:6: error: unreachable code", |
| 2580 | 2590 | ); |
| 2581 | 2591 | |
| 2582 | 2592 | cases.add( |
| ... | ... | @@ -2596,7 +2606,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2596 | 2606 | \\} |
| 2597 | 2607 | , |
| 2598 | 2608 | "tmp.zig:3:5: error: use of undeclared identifier 'b'", |
| 2599 | | "tmp.zig:4:5: error: use of undeclared identifier 'c'", |
| 2600 | 2609 | ); |
| 2601 | 2610 | |
| 2602 | 2611 | cases.add( |
| ... | ... | @@ -2662,7 +2671,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2662 | 2671 | \\ const a: noreturn = {}; |
| 2663 | 2672 | \\} |
| 2664 | 2673 | , |
| 2665 | | "tmp.zig:2:14: error: variable of type 'noreturn' not allowed", |
| 2674 | "tmp.zig:2:25: error: expected type 'noreturn', found 'void'", |
| 2666 | 2675 | ); |
| 2667 | 2676 | |
| 2668 | 2677 | cases.add( |
| ... | ... | @@ -2725,9 +2734,13 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2725 | 2734 | \\ var bad : bool = undefined; |
| 2726 | 2735 | \\ bad[bad] = bad[bad]; |
| 2727 | 2736 | \\} |
| 2737 | \\export fn g() void { |
| 2738 | \\ var bad : bool = undefined; |
| 2739 | \\ _ = bad[bad]; |
| 2740 | \\} |
| 2728 | 2741 | , |
| 2729 | 2742 | "tmp.zig:3:8: error: array access of non-array type 'bool'", |
| 2730 | | "tmp.zig:3:19: error: array access of non-array type 'bool'", |
| 2743 | "tmp.zig:7:12: error: array access of non-array type 'bool'", |
| 2731 | 2744 | ); |
| 2732 | 2745 | |
| 2733 | 2746 | cases.add( |
| ... | ... | @@ -2737,9 +2750,14 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2737 | 2750 | \\ var bad = false; |
| 2738 | 2751 | \\ array[bad] = array[bad]; |
| 2739 | 2752 | \\} |
| 2753 | \\export fn g() void { |
| 2754 | \\ var array = "aoeu"; |
| 2755 | \\ var bad = false; |
| 2756 | \\ _ = array[bad]; |
| 2757 | \\} |
| 2740 | 2758 | , |
| 2741 | 2759 | "tmp.zig:4:11: error: expected type 'usize', found 'bool'", |
| 2742 | | "tmp.zig:4:24: error: expected type 'usize', found 'bool'", |
| 2760 | "tmp.zig:9:15: error: expected type 'usize', found 'bool'", |
| 2743 | 2761 | ); |
| 2744 | 2762 | |
| 2745 | 2763 | cases.add( |
| ... | ... | @@ -2757,12 +2775,14 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2757 | 2775 | "missing else clause", |
| 2758 | 2776 | \\fn f(b: bool) void { |
| 2759 | 2777 | \\ const x : i32 = if (b) h: { break :h 1; }; |
| 2778 | \\} |
| 2779 | \\fn g(b: bool) void { |
| 2760 | 2780 | \\ const y = if (b) h: { break :h i32(1); }; |
| 2761 | 2781 | \\} |
| 2762 | | \\export fn entry() void { f(true); } |
| 2782 | \\export fn entry() void { f(true); g(true); } |
| 2763 | 2783 | , |
| 2764 | 2784 | "tmp.zig:2:42: error: integer value 1 cannot be implicitly casted to type 'void'", |
| 2765 | | "tmp.zig:3:15: error: incompatible types: 'i32' and 'void'", |
| 2785 | "tmp.zig:5:15: error: incompatible types: 'i32' and 'void'", |
| 2766 | 2786 | ); |
| 2767 | 2787 | |
| 2768 | 2788 | cases.add( |
| ... | ... | @@ -2773,9 +2793,13 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2773 | 2793 | \\ a.foo = 1; |
| 2774 | 2794 | \\ const y = a.bar; |
| 2775 | 2795 | \\} |
| 2796 | \\export fn g() void { |
| 2797 | \\ var a : A = undefined; |
| 2798 | \\ const y = a.bar; |
| 2799 | \\} |
| 2776 | 2800 | , |
| 2777 | 2801 | "tmp.zig:4:6: error: no member named 'foo' in struct 'A'", |
| 2778 | | "tmp.zig:5:16: error: no member named 'bar' in struct 'A'", |
| 2802 | "tmp.zig:9:16: error: no member named 'bar' in struct 'A'", |
| 2779 | 2803 | ); |
| 2780 | 2804 | |
| 2781 | 2805 | cases.add( |
| ... | ... | @@ -2920,7 +2944,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2920 | 2944 | \\ _ = foo; |
| 2921 | 2945 | \\} |
| 2922 | 2946 | , |
| 2923 | | "tmp.zig:1:19: error: type '[3]u16' does not support struct initialization syntax", |
| 2947 | "tmp.zig:1:21: error: type '[3]u16' does not support struct initialization syntax", |
| 2924 | 2948 | ); |
| 2925 | 2949 | |
| 2926 | 2950 | cases.add( |
| ... | ... | @@ -3239,7 +3263,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3239 | 3263 | \\ |
| 3240 | 3264 | \\export fn entry() usize { return @sizeOf(@typeOf(Foo)); } |
| 3241 | 3265 | , |
| 3242 | | "tmp.zig:5:25: error: unable to evaluate constant expression", |
| 3266 | "tmp.zig:5:18: error: unable to evaluate constant expression", |
| 3243 | 3267 | "tmp.zig:2:12: note: called from here", |
| 3244 | 3268 | "tmp.zig:2:8: note: called from here", |
| 3245 | 3269 | ); |