diff --git a/test/cases/compile_errors/implicit_cast_const_array_to_mutable_slice.zig b/test/cases/compile_errors/implicit_cast_const_array_to_mutable_slice.zig index 2a80b9ffbc..6f67f72525 100644 --- a/test/cases/compile_errors/implicit_cast_const_array_to_mutable_slice.zig +++ b/test/cases/compile_errors/implicit_cast_const_array_to_mutable_slice.zig @@ -13,6 +13,11 @@ export fn entry2() void { const many: [*]u8 = str; _ = many; } +export fn entry3() void { + const lang: []const u8 = "lang"; + const targets: [1][]const u8 = [_][]u8{lang}; + _ = targets; +} // error // backend=stage2 @@ -24,3 +29,5 @@ export fn entry2() void { // :8:27: note: cast discards const qualifier // :13:25: error: expected type '[*]u8', found '*const [0:0]u8' // :13:25: note: cast discards const qualifier +// :18:44: error: expected type '[]u8', found '[]const u8' +// :18:44: note: cast discards const qualifier diff --git a/test/cases/compile_errors/invalid_store_to_comptime_field.zig b/test/cases/compile_errors/invalid_store_to_comptime_field.zig index a86cb500d2..89deda92d4 100644 --- a/test/cases/compile_errors/invalid_store_to_comptime_field.zig +++ b/test/cases/compile_errors/invalid_store_to_comptime_field.zig @@ -61,6 +61,11 @@ pub export fn entry6() void { }; _ = State.init(false); } +pub export fn entry7() void { + const list1 = .{ "sss", 1, 2, 3 }; + const list2 = @TypeOf(list1){ .@"0" = "xxx", .@"1" = 4, .@"2" = 5, .@"3" = 6 }; + _ = list2; +} // error // target=native @@ -73,4 +78,5 @@ pub export fn entry6() void { // :25:29: note: default value set here // :41:16: error: value stored in comptime field does not match the default value of the field // :45:12: error: value stored in comptime field does not match the default value of the field +// :66:43: error: value stored in comptime field does not match the default value of the field // :59:35: error: value stored in comptime field does not match the default value of the field diff --git a/test/cases/compile_errors/invalid_struct_field.zig b/test/cases/compile_errors/invalid_struct_field.zig index d351a012f9..4450375cb8 100644 --- a/test/cases/compile_errors/invalid_struct_field.zig +++ b/test/cases/compile_errors/invalid_struct_field.zig @@ -1,15 +1,22 @@ -const A = struct { x : i32, }; +const A = struct { x: i32 }; export fn f() void { - var a : A = undefined; + var a: A = undefined; a.foo = 1; const y = a.bar; _ = y; } export fn g() void { - var a : A = undefined; + var a: A = undefined; const y = a.bar; _ = y; } +export fn e() void { + const B = struct { + fn f() void {} + }; + const b: B = undefined; + @import("std").debug.print("{}{}", .{ b.f, b.f }); +} // error // backend=stage2 @@ -18,4 +25,5 @@ export fn g() void { // :4:7: error: no field named 'foo' in struct 'tmp.A' // :1:11: note: struct declared here // :10:17: error: no field named 'bar' in struct 'tmp.A' - +// :18:45: error: no field named 'f' in struct 'tmp.e.B' +// :14:15: note: struct declared here