| 1 | #exe { |
| 2 | -Mroot=main.zig |
| 3 | #} |
| 4 | |
| 5 | #write main.zig { |
| 6 | const std = @import("std"); |
| 7 | const io = std.Io.Threaded.global_single_threaded.io(); |
| 8 | |
| 9 | const A = enum(u32) { |
| 10 | zero, |
| 11 | one, |
| 12 | }; |
| 13 | |
| 14 | fn foo() !void { |
| 15 | try bar(.zero); |
| 16 | } |
| 17 | |
| 18 | fn bar(a: A) !void { |
| 19 | const msg = switch (a) { |
| 20 | .zero => "0", |
| 21 | .one => "1", |
| 22 | }; |
| 23 | try std.Io.File.stdout().writeStreamingAll(io, msg); |
| 24 | } |
| 25 | |
| 26 | pub fn main() !void { |
| 27 | try foo(); |
| 28 | } |
| 29 | #} |
| 30 | #update |
| 31 | #check stdout "0" |
| 32 | |
| 33 | #write main.zig { |
| 34 | //! This update must preserve `bar` `InternPool.Index` value, while changing its wasm function type. |
| 35 | //! If `foo` code is preserved in the binary without any changes, wasm type checking will fail. |
| 36 | const std = @import("std"); |
| 37 | const io = std.Io.Threaded.global_single_threaded.io(); |
| 38 | |
| 39 | const A = enum(u64) { |
| 40 | zero, |
| 41 | one, |
| 42 | }; |
| 43 | |
| 44 | fn bar(a: A) !void { |
| 45 | const msg = switch (a) { |
| 46 | .zero => "0", |
| 47 | .one => "1", |
| 48 | }; |
| 49 | try std.Io.File.stdout().writeStreamingAll(io, msg); |
| 50 | } |
| 51 | |
| 52 | pub fn main() !void { |
| 53 | try bar(.one); |
| 54 | } |
| 55 | #} |
| 56 | #update "remove foo and change bar wasm function type" |
| 57 | #check stdout "1" |