incremental: fix enum resolution bugs
This commit is contained in:
59
test/incremental/change_enum_tag_type
Normal file
59
test/incremental/change_enum_tag_type
Normal file
@@ -0,0 +1,59 @@
|
||||
#target=x86_64-linux-selfhosted
|
||||
#target=x86_64-linux-cbe
|
||||
#target=x86_64-windows-cbe
|
||||
#target=wasm32-wasi-selfhosted
|
||||
#update=initial version
|
||||
#file=main.zig
|
||||
const Tag = u2;
|
||||
const Foo = enum(Tag) {
|
||||
a,
|
||||
b,
|
||||
c,
|
||||
d,
|
||||
};
|
||||
pub fn main() !void {
|
||||
var val: Foo = undefined;
|
||||
val = .a;
|
||||
try std.io.getStdOut().writer().print("{s}\n", .{@tagName(val)});
|
||||
}
|
||||
const std = @import("std");
|
||||
#expect_stdout="a\n"
|
||||
#update=too many enum fields
|
||||
#file=main.zig
|
||||
const Tag = u2;
|
||||
const Foo = enum(Tag) {
|
||||
a,
|
||||
b,
|
||||
c,
|
||||
d,
|
||||
e,
|
||||
};
|
||||
pub fn main() !void {
|
||||
var val: Foo = undefined;
|
||||
val = .a;
|
||||
try std.io.getStdOut().writer().print("{s}\n", .{@tagName(val)});
|
||||
}
|
||||
comptime {
|
||||
// These can't be true at the same time; analysis should stop as soon as it sees `Foo`
|
||||
std.debug.assert(@intFromEnum(Foo.e) == 4);
|
||||
std.debug.assert(@TypeOf(@intFromEnum(Foo.e)) == Tag);
|
||||
}
|
||||
const std = @import("std");
|
||||
#expect_error=ignored
|
||||
#update=increase tag size
|
||||
#file=main.zig
|
||||
const Tag = u3;
|
||||
const Foo = enum(Tag) {
|
||||
a,
|
||||
b,
|
||||
c,
|
||||
d,
|
||||
e,
|
||||
};
|
||||
pub fn main() !void {
|
||||
var val: Foo = undefined;
|
||||
val = .a;
|
||||
try std.io.getStdOut().writer().print("{s}\n", .{@tagName(val)});
|
||||
}
|
||||
const std = @import("std");
|
||||
#expect_stdout="a\n"
|
||||
Reference in New Issue
Block a user