diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-08-28 13:17:25 +0300 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-08-28 15:41:21 +0300 |
| commit | 6aead18ab332a3cf809b5c824d70cdc52f0e5156 (patch) | |
| tree | 356d513370db47c2159c534e02cf91514d2ba914 /test | |
| parent | 1401890ed5194aff3469be0b6919fd8fe2614c7b (diff) | |
| download | zig-6aead18ab332a3cf809b5c824d70cdc52f0e5156.tar.gz zig-6aead18ab332a3cf809b5c824d70cdc52f0e5156.zip | |
add error tests for now correctly behaving cases
Closes #6377
Diffstat (limited to 'test')
| -rw-r--r-- | test/cases/compile_errors/duplicate_field_in_discarded_anon_init.zig | 10 | ||||
| -rw-r--r-- | test/cases/compile_errors/struct_init_passed_to_type_param.zig | 14 |
2 files changed, 24 insertions, 0 deletions
diff --git a/test/cases/compile_errors/duplicate_field_in_discarded_anon_init.zig b/test/cases/compile_errors/duplicate_field_in_discarded_anon_init.zig new file mode 100644 index 0000000000..6f850e6fe4 --- /dev/null +++ b/test/cases/compile_errors/duplicate_field_in_discarded_anon_init.zig @@ -0,0 +1,10 @@ +pub export fn entry() void { + _ = .{ .a = 0, .a = 1 }; +} + +// error +// backend=stage2 +// target=native +// +// :2:21: error: duplicate field +// :2:13: note: other field here diff --git a/test/cases/compile_errors/struct_init_passed_to_type_param.zig b/test/cases/compile_errors/struct_init_passed_to_type_param.zig new file mode 100644 index 0000000000..b00c27986f --- /dev/null +++ b/test/cases/compile_errors/struct_init_passed_to_type_param.zig @@ -0,0 +1,14 @@ +const MyStruct = struct { x: i32 }; + +fn hi(comptime T: type) usize { + return @sizeOf(T); +} + +export const value = hi(MyStruct{ .x = 12 }); + +// error +// backend=stage2 +// target=native +// +// :7:33: error: expected type 'type', found 'tmp.MyStruct' +// :1:18: note: struct declared here |
