mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
add behavior test: avoid unused field function body compile error
This commit is contained in:
parent
500afbf076
commit
1c9ac9dbb7
@ -2153,3 +2153,26 @@ test "align 1 struct parameter dereferenced and returned" {
|
||||
.little => try expect(s.a == 0x05040302),
|
||||
}
|
||||
}
|
||||
|
||||
test "avoid unused field function body compile error" {
|
||||
const Case = struct {
|
||||
const This = @This();
|
||||
|
||||
const S = struct {
|
||||
a: usize = 1,
|
||||
b: fn () void = This.functionThatDoesNotCompile,
|
||||
};
|
||||
|
||||
const s: S = .{};
|
||||
|
||||
fn entry() usize {
|
||||
return s.a;
|
||||
}
|
||||
|
||||
pub fn functionThatDoesNotCompile() void {
|
||||
@compileError("told you so");
|
||||
}
|
||||
};
|
||||
|
||||
try expect(Case.entry() == 1);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user