mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-10-29 11:15:47 +08:00
61 lines
1.0 KiB
Plaintext
61 lines
1.0 KiB
Plaintext
#exe {
|
|
-Mroot=main.zig
|
|
#}
|
|
|
|
#write main.zig {
|
|
const std = @import("std");
|
|
const io = std.Io.Threaded.global_single_threaded.io();
|
|
|
|
const A = enum(u32) {
|
|
zero,
|
|
one,
|
|
};
|
|
|
|
fn foo() !void {
|
|
try bar(.zero);
|
|
}
|
|
|
|
fn bar(a: A) !void {
|
|
const msg = switch (a) {
|
|
.zero => "0",
|
|
.one => "1",
|
|
};
|
|
try std.Io.File.stdout().writeStreamingAll(io, msg);
|
|
}
|
|
|
|
pub fn main() !void {
|
|
try foo();
|
|
}
|
|
#}
|
|
#update
|
|
#check stdout {
|
|
0#}
|
|
|
|
#write main.zig {
|
|
//! This update must preserve `bar` `InternPool.Index` value, while changing its wasm function type.
|
|
//! If `foo` code is preserved in the binary without any changes, wasm type checking will fail.
|
|
const std = @import("std");
|
|
const io = std.Io.Threaded.global_single_threaded.io();
|
|
|
|
const A = enum(u64) {
|
|
zero,
|
|
one,
|
|
};
|
|
|
|
fn bar(a: A) !void {
|
|
const msg = switch (a) {
|
|
.zero => "0",
|
|
.one => "1",
|
|
};
|
|
try std.Io.File.stdout().writeStreamingAll(io, msg);
|
|
}
|
|
|
|
pub fn main() !void {
|
|
try bar(.one);
|
|
}
|
|
#}
|
|
#update {
|
|
remove foo and change bar wasm function type#}
|
|
#check stdout {
|
|
1#}
|