aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/compile_errors.zig')
-rw-r--r--test/compile_errors.zig27
1 files changed, 15 insertions, 12 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index fbecacb94b..7ee5896568 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -3,6 +3,21 @@ const builtin = @import("builtin");
pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add(
+ "compile error in struct init expression",
+ \\const Foo = struct {
+ \\ a: i32 = crap,
+ \\ b: i32,
+ \\};
+ \\export fn entry() void {
+ \\ var x = Foo{
+ \\ .b = 5,
+ \\ };
+ \\}
+ ,
+ "tmp.zig:2:14: error: use of undeclared identifier 'crap'",
+ );
+
+ cases.add(
"undefined as field type is rejected",
\\const Foo = struct {
\\ a: undefined,
@@ -5485,18 +5500,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
);
cases.add(
- "struct fields with value assignments",
- \\const MultipleChoice = struct {
- \\ A: i32 = 20,
- \\};
- \\export fn entry() void {
- \\ var x: MultipleChoice = undefined;
- \\}
- ,
- "tmp.zig:2:14: error: enums, not structs, support field assignment",
- );
-
- cases.add(
"union fields with value assignments",
\\const MultipleChoice = union {
\\ A: i32 = 20,