✓
Passing This code compiles and runs correctly.
Code
// TEST: std/fmt:ln spliced MID-CHAIN between branch-outcome handler calls.
//
// Pins the emitter result_N collision: the flow emitter names handler
// results result_<counter>, and the transform/inline-expansion splice
// (std/fmt:ln's inline_body) misaligned the counter so an inner handler
// result collapsed onto an outer one:
//
// error: local constant 'result_1' shadows local constant from outer scope
//
// Shape mirrors openssl/examples/02_interp_write.kz (the live repro) but
// with a dependency-free sibling module: connect -> fmt:ln -> write ->
// read -> shutdown, each returning | ok / | err outcomes so the emitter
// nests switches. Without the fmt:ln hop the same chain numbers uniquely.
~import app/net
~import std/fmt
~app/net:connect(host: "localhost")
| ok c |> std/fmt:ln("GET /conn/{{ c:d }}")
| line req |> app/net:write(conn: c, data: req.text)
| ok w |> app/net:read(conn: w)
| ok r |> app/net:shutdown(r.conn)
| ok |> _
| err _ |> _
| err _ |> _
| err _ |> _
| err _ |> _
Actual
write: GET /conn/7
read from conn 7
shutdown conn 7
Expected output
write: GET /conn/7
read from conn 7
shutdown conn 7
Flows
flow ~connect click a branch to expand · @labels scroll to their anchor
connect (host: "localhost")
Imported Files
// Minimal network-shaped module: a chain of branch-outcome events
// (connect -> write -> read -> shutdown) with | ok / | err branches,
// used to pin the emitter result_N collision when a std/fmt:ln hop
// is spliced into the chain.
const std = @import("std");
~pub event connect { host: []const u8 }
| ok i32
| err []const u8
~proc connect|zig {
_ = host;
return .{ .ok = 7 };
}
~pub event write { conn: i32, data: []const u8 }
| ok i32
| err []const u8
~proc write|zig {
std.debug.print("write: {s}\n", .{data});
return .{ .ok = conn };
}
~pub event read { conn: i32 }
| ok { conn: i32, n: i32 }
| err []const u8
~proc read|zig {
std.debug.print("read from conn {d}\n", .{conn});
return .{ .ok = .{ .conn = conn, .n = 42 } };
}
~pub event shutdown { conn: i32 }
| ok
| err []const u8
~proc shutdown|zig {
std.debug.print("shutdown conn {d}\n", .{conn});
return .{ .ok = .{} };
}
Test Configuration
MUST_RUN