cases: more test coverage

Closes #11986
Closes #11850
Closes #12159
This commit is contained in:
r00ster91 2022-12-15 21:54:03 +01:00
parent 5ecc2b99af
commit a429f72ae8
3 changed files with 25 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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