✓
Passing This code compiles and runs correctly.
Code
// NESTING SWEEP — event-glob comptime-transform invocation nested under an
// OBLIGATION branch (`| ok s |>`).
//
// Component A: comptime|transform glob event decl + bare-name invocation,
// grounded in tests/regression/200_COMPILER_FEATURES/220_COMPILATION/
// 220_013_many_transforms_no_cap/input.kz:20-26 (event t1.* decl + proc
// t1.*|zig handler, replacement = inline-code comment) and :162 (bare
// `~t1.fire("x")` flow-head invocation matched + replaced, MUST_RUN, green).
//
// Component B: an obligation branch (`std/string:from-page` -> `| ok s |>`
// .. `| err _ |>`, discharged via `std/string:free(s)` on every terminal),
// grounded in 670_012_capture_under_obligation/input.k:9-13 and
// 670_022_readlines_under_obligation/input.k:9-14 (arbitrary invocations
// legally sit as the `| ok s |>` payload there), and
// 300_ADVANCED_FEATURES/335_OBLIGATION_STRESS/335_021_instance_no_explicit_free/
// input.kz:14-19 (`~` marks flow-head only; mid-chain steps carry no tilde,
// in a .kz host-embedded file).
//
// Composition: the glob-matched invocation itself (no leading `~`, same
// mid-chain-invocation shape as `work()` in 020_006_void_pipeline_sequence:12)
// sits as the `| ok s |>` payload, chained onward to std/string:free(s). The
// transform must fire at this mid-chain site exactly as it does at flow-head,
// replacing only its own step, and the obligation discharge that follows it
// in the same chain must still run.
~import std/io
~import std/string
~[comptime|transform]tor t1.* {
expr: Expression,
item: *const Item,
program: *const Program,
} -> SiteResult
~proc t1.*|zig {
const ast = @import("ast");
const allocator = @import("std").heap.page_allocator;
const flow = if (item.* == .flow) &item.flow else return .{};
return .{ .replacement = ast.Item{ .inline_code = .{ .code = "// t1 ran", .location = flow.location, .module = allocator.dupe(u8, flow.module) catch return .{} } } };
}
~std/string:from-page(text: "x")
| ok s |> t1.fire("x") |> std/string:free(s)
| err _ |> std/io:print.ln("err")
Flows
flow ~from-page click a branch to expand · @labels scroll to their anchor
from-page (text: "x")
Test Configuration
MUST_RUN