mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
parent
5ecc2b99af
commit
a429f72ae8
@ -13,6 +13,11 @@ export fn entry2() void {
|
|||||||
const many: [*]u8 = str;
|
const many: [*]u8 = str;
|
||||||
_ = many;
|
_ = many;
|
||||||
}
|
}
|
||||||
|
export fn entry3() void {
|
||||||
|
const lang: []const u8 = "lang";
|
||||||
|
const targets: [1][]const u8 = [_][]u8{lang};
|
||||||
|
_ = targets;
|
||||||
|
}
|
||||||
|
|
||||||
// error
|
// error
|
||||||
// backend=stage2
|
// backend=stage2
|
||||||
@ -24,3 +29,5 @@ export fn entry2() void {
|
|||||||
// :8:27: note: cast discards const qualifier
|
// :8:27: note: cast discards const qualifier
|
||||||
// :13:25: error: expected type '[*]u8', found '*const [0:0]u8'
|
// :13:25: error: expected type '[*]u8', found '*const [0:0]u8'
|
||||||
// :13:25: note: cast discards const qualifier
|
// :13:25: note: cast discards const qualifier
|
||||||
|
// :18:44: error: expected type '[]u8', found '[]const u8'
|
||||||
|
// :18:44: note: cast discards const qualifier
|
||||||
|
|||||||
@ -61,6 +61,11 @@ pub export fn entry6() void {
|
|||||||
};
|
};
|
||||||
_ = State.init(false);
|
_ = 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
|
// error
|
||||||
// target=native
|
// target=native
|
||||||
@ -73,4 +78,5 @@ pub export fn entry6() void {
|
|||||||
// :25:29: note: default value set here
|
// :25:29: note: default value set here
|
||||||
// :41:16: error: value stored in comptime field does not match the default value of the field
|
// :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
|
// :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
|
// :59:35: error: value stored in comptime field does not match the default value of the field
|
||||||
|
|||||||
@ -1,15 +1,22 @@
|
|||||||
const A = struct { x : i32, };
|
const A = struct { x: i32 };
|
||||||
export fn f() void {
|
export fn f() void {
|
||||||
var a : A = undefined;
|
var a: A = undefined;
|
||||||
a.foo = 1;
|
a.foo = 1;
|
||||||
const y = a.bar;
|
const y = a.bar;
|
||||||
_ = y;
|
_ = y;
|
||||||
}
|
}
|
||||||
export fn g() void {
|
export fn g() void {
|
||||||
var a : A = undefined;
|
var a: A = undefined;
|
||||||
const y = a.bar;
|
const y = a.bar;
|
||||||
_ = y;
|
_ = y;
|
||||||
}
|
}
|
||||||
|
export fn e() void {
|
||||||
|
const B = struct {
|
||||||
|
fn f() void {}
|
||||||
|
};
|
||||||
|
const b: B = undefined;
|
||||||
|
@import("std").debug.print("{}{}", .{ b.f, b.f });
|
||||||
|
}
|
||||||
|
|
||||||
// error
|
// error
|
||||||
// backend=stage2
|
// backend=stage2
|
||||||
@ -18,4 +25,5 @@ export fn g() void {
|
|||||||
// :4:7: error: no field named 'foo' in struct 'tmp.A'
|
// :4:7: error: no field named 'foo' in struct 'tmp.A'
|
||||||
// :1:11: note: struct declared here
|
// :1:11: note: struct declared here
|
||||||
// :10:17: error: no field named 'bar' in struct 'tmp.A'
|
// :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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user