✓
Passing This code compiles and runs correctly.
Code
// PINS: a phantom-typed BORROW minted outside a sweep is usable INSIDE
// `std/store:query`'s arm.
//
// `xs` is a `<list!>` handle from `| list xs`. The arm pushes to it once per
// row and reads its length back, so the output proves it is the SAME list
// accumulating — 1, 2, 3 — and not a fresh one per iteration.
//
// This was refused, and the store's sweep was the ONLY construct that refused
// it. The same borrow threads into `for(0..N) ! each` and into
// `std/fs:read-lines`' `! line` arm, where 810_242_day24_part2 has pushed regex
// captures into a list for weeks.
//
// THE CAUSE WAS NOT THE LOWERING, which is what made it worth chasing rather
// than working around. A sweep body is transplanted into a separate event
// (`__store_sweepbody_<s>_L<n>`) whose inputs carry the captures the body
// references, and that threading ALREADY worked — a plain `i64` bound outside
// the sweep arrives inside it correctly. What it dropped was the phantom:
// `lookupBranchIn` read the branch payload's type and module and left its
// `<state!>` behind, so the synthesized input declared a bare type and the
// checker, correctly, saw a name with no tracked state.
//
// Three things had to be right and each one produced its own diagnostic on the
// way, which is worth recording because they read like unrelated bugs:
//
// phantom dropped -> "argument 'xs' has no tracked phantom state"
// phantom kept as-is -> KORU033, "Cannot issue obligation '<list!>' on
// input parameter" — an input may BORROW a state but
// never mint one
// phantom unqualified -> "expected 'std.list:list' but got '<prog>:list'",
// the state resolving against the consumer's module
//
// So the capture now carries the payload's obligation, qualified with the
// module that declared it, and the synthesized input demotes it to a bare
// borrow — the same demotion an owned column's projection already made. The arm
// may read and mutate the handle; it must not be asked to DISCHARGE it, because
// the obligation belongs to the enclosing scope and the body runs once per row.
//
// KNOWN REMAINING GAP: this uses `new-i64`, the concrete constructor. Going
// through `std/list:new(i64)` — a `[comptime|transform]` that rewrites to it —
// still fails, because the capture collector reads branches off the invocation
// path and the transform event declares none. That is a transform-ordering
// question, narrower than this one, and not fixed here.
import std/io
import std/store
import std/list
std/store:new(items, capacity: 8) { v: i64 }
std/store:insert(items) { v: 10 }
| row _ |> _
std/store:insert(items) { v: 20 }
| row _ |> _
std/store:insert(items) { v: 30 }
| row _ |> _
std/list:new-i64()
| list xs |> std/store:query(items)
! query e |> std/list:push(xs, e.v) |> std/list:len(xs): n |> std/io:print.ln("pushed {{ e.v:d }}, len {{ n:d }}")
| err _ |> std/io:print.ln("list failed")
Actual · Zig
✓ passpushed 10, len 1
pushed 20, len 2
pushed 30, len 3
Actual · C#
✗ cs-compileExpected output
✓ Zig✗ C#pushed 10, len 1
pushed 20, len 2
pushed 30, len 3
Emitted Zig source
// Access compiler flags via the per-user compiler_env module
const CompilerEnv = @import("compiler_env").CompilerEnv;
pub const panic = if (@import("builtin").mode == .Debug)
@import("std").debug.FullPanic(@import("std").debug.defaultPanic)
else
@import("std").debug.simple_panic;
const __koru_bare = struct {
extern fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int;
extern fn free(ptr: ?*anyopaque) void;
fn bareAlloc(_: *anyopaque, len: usize, alignment: @import("std").mem.Alignment, _: usize) ?[*]u8 {
var p: ?*anyopaque = null;
const a = @max(alignment.toByteUnits(), @sizeOf(usize));
if (posix_memalign(&p, a, len) != 0) return null;
return @ptrCast(p);
}
fn bareResize(_: *anyopaque, _: []u8, _: @import("std").mem.Alignment, _: usize, _: usize) bool { return false; }
fn bareRemap(_: *anyopaque, _: []u8, _: @import("std").mem.Alignment, _: usize, _: usize) ?[*]u8 { return null; }
fn bareFree(_: *anyopaque, memory: []u8, _: @import("std").mem.Alignment, _: usize) void { free(@ptrCast(memory.ptr)); }
const vtable = @import("std").mem.Allocator.VTable{ .alloc = bareAlloc, .resize = bareResize, .remap = bareRemap, .free = bareFree };
const allocator = @import("std").mem.Allocator{ .ptr = undefined, .vtable = &vtable };
};
const __koru_backing = if (@import("builtin").link_libc) @import("std").heap.c_allocator else if (@import("builtin").os.tag == .freestanding) __koru_bare.allocator else @import("std").heap.page_allocator;
var __koru_leak_count: @import("std").atomic.Value(usize) = .init(0);
fn __koru_alloc(ctx: *anyopaque, len: usize, alignment: @import("std").mem.Alignment, ret_addr: usize) ?[*]u8 {
_ = ctx;
const r = __koru_backing.rawAlloc(len, alignment, ret_addr);
if (comptime @import("builtin").mode == .Debug) {
if (r != null) _ = __koru_leak_count.fetchAdd(1, .monotonic);
}
return r;
}
fn __koru_resize(ctx: *anyopaque, memory: []u8, alignment: @import("std").mem.Alignment, new_len: usize, ret_addr: usize) bool {
_ = ctx;
return __koru_backing.rawResize(memory, alignment, new_len, ret_addr);
}
fn __koru_remap(ctx: *anyopaque, memory: []u8, alignment: @import("std").mem.Alignment, new_len: usize, ret_addr: usize) ?[*]u8 {
_ = ctx;
return __koru_backing.rawRemap(memory, alignment, new_len, ret_addr);
}
fn __koru_free(ctx: *anyopaque, memory: []u8, alignment: @import("std").mem.Alignment, ret_addr: usize) void {
_ = ctx;
__koru_backing.rawFree(memory, alignment, ret_addr);
if (comptime @import("builtin").mode == .Debug) {
_ = __koru_leak_count.fetchSub(1, .monotonic);
}
}
const __koru_vtable = @import("std").mem.Allocator.VTable{ .alloc = __koru_alloc, .resize = __koru_resize, .remap = __koru_remap, .free = __koru_free };
pub fn koru_allocator() @import("std").mem.Allocator {
return .{ .ptr = undefined, .vtable = &__koru_vtable };
}
pub inline fn __koru_intcast(comptime T: type, x: anytype) T {
if (comptime (@import("builtin").mode == .Debug or @import("builtin").mode == .ReleaseSafe))
return @as(T, @intCast(x));
const dst = @typeInfo(T);
const src = @typeInfo(@TypeOf(x));
if (comptime (dst == .int and src == .int and dst.int.bits == src.int.bits and dst.int.signedness != src.int.signedness))
return @as(T, @bitCast(x));
return @as(T, @intCast(x));
}
pub fn koru_leak_check() void {
if (comptime @import("builtin").mode != .Debug) return;
if (__koru_leak_count.load(.acquire) == 0) return;
if (comptime @import("builtin").target.os.tag == .freestanding) {
if (comptime @import("builtin").cpu.arch == .wasm32 or @import("builtin").cpu.arch == .wasm64) {
@panic("KORU LEAK CHECK FAILED: the produced program leaked");
} else {
const __klc = struct { extern var stdout: ?*anyopaque; extern fn fputs(__s: [*:0]const u8, __st: ?*anyopaque) c_int; };
var __lb: [128]u8 = undefined;
const __lm = "KORU LEAK CHECK FAILED: allocations still outstanding at end of run: ";
@memcpy(__lb[0..__lm.len], __lm);
var __ln: usize = __lm.len;
var __lv = __koru_leak_count.load(.acquire);
var __ld: [20]u8 = undefined;
var __lk: usize = 0;
while (__lv > 0) : (__lk += 1) { __ld[__lk] = @intCast('0' + __lv % 10); __lv /= 10; }
for (0..__lk) |__li| { __lb[__ln] = __ld[__lk - 1 - __li]; __ln += 1; }
__lb[__ln] = '\n'; __ln += 1; __lb[__ln] = 0;
_ = __klc.fputs(@as([*:0]const u8, @ptrCast(&__lb)), __klc.stdout);
@trap();
}
} else {
@import("std").debug.print("KORU LEAK CHECK FAILED: the produced program leaked (trace above)\n", .{});
@import("std").process.exit(1);
}
}
pub const main_module = struct {
// std/store: plural store 'items' created (SoA cell + insert/query/write/take/stripe units); fields v: i64
// >>> FLOW: tests/regression/600_STDLIB/690_STORE/690_252_phantom_borrow_crosses_into_a_query_arm/input.k:50 ~input:__store_inserth_items()
pub fn flow0() void {
const result_0 = main_module.__store_inserth_items_event.handler(.{ .v = 10, .__site_line = 50 });
const _auto_6 = result_0.row;
_ = &_auto_6;
}
// >>> FLOW: tests/regression/600_STDLIB/690_STORE/690_252_phantom_borrow_crosses_into_a_query_arm/input.k:52 ~input:__store_inserth_items()
pub fn flow1() void {
const result_0 = main_module.__store_inserth_items_event.handler(.{ .v = 20, .__site_line = 52 });
const _auto_7 = result_0.row;
_ = &_auto_7;
}
// >>> FLOW: tests/regression/600_STDLIB/690_STORE/690_252_phantom_borrow_crosses_into_a_query_arm/input.k:54 ~input:__store_inserth_items()
pub fn flow2() void {
const result_0 = main_module.__store_inserth_items_event.handler(.{ .v = 30, .__site_line = 54 });
const _auto_8 = result_0.row;
_ = &_auto_8;
}
// >>> FLOW: tests/regression/600_STDLIB/690_STORE/690_252_phantom_borrow_crosses_into_a_query_arm/input.k:57 ~std.list:new_i64()
pub fn flow3() void {
const result_0 = koru_std.koru_list.new_i64_event.handler(.{ });
switch (result_0) {
// >>> BRANCH: tests/regression/600_STDLIB/690_STORE/690_252_phantom_borrow_crosses_into_a_query_arm/input.k:60 | err _auto_9 |>
.err => |_| {
(struct { fn __kout(__fd: i32, __b: []const u8) void { if (@import("builtin").os.tag == .freestanding) { const __kc = struct { extern var stdout: ?*anyopaque; extern var stderr: ?*anyopaque; extern fn fputs(__s: [*:0]const u8, __st: ?*anyopaque) c_int; }; var __kt: [4096]u8 = undefined; for (0..(__b.len + __kt.len - 2) / (__kt.len - 1)) |__ki| { const __kn = @min(__kt.len - 1, __b.len - __ki * (__kt.len - 1)); @memcpy(__kt[0..__kn], __b[__ki * (__kt.len - 1)..][0..__kn]); __kt[__kn] = 0; @import("std").mem.doNotOptimizeAway(__kc.fputs(@as([*:0]const u8, @ptrCast(&__kt)), if (__fd == 2) __kc.stderr else __kc.stdout)); } } else { @import("std").mem.doNotOptimizeAway(@import("std").posix.write(__fd, __b) catch @as(usize, 0)); } } fn __kw(comptime __f: []const u8, __a: anytype) void { var __kb: [65536]u8 = undefined; const __ks = @import("std").fmt.bufPrint(&__kb, __f, __a) catch __kb[0..0]; __kout(1, __ks); } }).__kw("list failed\n", .{});
},
// >>> BRANCH: tests/regression/600_STDLIB/690_STORE/690_252_phantom_borrow_crosses_into_a_query_arm/input.k:58 | list xs |>
.list => |xs| {
{
for (0..main_module.__koru_store_items.len) |__koru_si| {
const __koru_srf_e_L59_v = main_module.__koru_store_items.v[__koru_si];
_ = &__koru_srf_e_L59_v;
main_module.__store_sweepbody_items_L59_690_252_phantom_borrow_crosses_into_a_query_arm_input_6c3f0e_event.handler(.{ .__koru_srf_e_L59_v = __koru_srf_e_L59_v, .xs = xs, .__koru_sdix_e_L59 = __koru_si });
}
}
_ = koru_std.koru_list.free_i64_event.handler(.{ .xs = xs });
},
}
}
pub fn koru_start_flow() void {
const result_0 = koru_koru.start_event.handler(.{ });
const result_0_done = result_0.done;
_ = &result_0_done;
}
pub fn koru_end_flow() void {
const result_0 = koru_koru.end_event.handler(.{ });
const result_0_done = result_0.done;
_ = &result_0_done;
}
const __KoruStoreT_items = struct {
v: [8]i64 = undefined,
len: usize = 0,
};
var __koru_store_items: __KoruStoreT_items = .{};
const __KoruStoreRow_items = struct { v: i64 };
pub const __store_inserth_items_event = struct {
pub const Input = struct {
v: i64,
__site_line: i64,
};
pub const Output = union(enum(u8)) {
row: i64,
};
pub inline fn handler(__koru_event_input: @This().Input) @This().Output {
return __koru_handler_impl(__koru_event_input.v, __koru_event_input.__site_line);
}
fn __koru_handler_impl(__koru_p_0: i64, __koru_p_1: i64) @This().Output {
const __koru_event_input: @This().Input = .{ .v = __koru_p_0, .__site_line = __koru_p_1 };
// >>> PROC: __store_inserth_items [tests/regression/600_STDLIB/690_STORE/690_252_phantom_borrow_crosses_into_a_query_arm/input.k:48]
const v = __koru_event_input.v;
const __site_line = __koru_event_input.__site_line;
_ = &v;
_ = &__site_line;
_ = &__koru_event_input;
if (__koru_store_items.len >= 8) @panic("std/store: store 'items' is full (capacity 8) - declared capacity and the `| full` branch are pinned at 690_011");
const __koru_new_row = __koru_store_items.len;
__koru_store_items.v[__koru_new_row] = v;
__koru_store_items.len += 1;
return .{ .row = @as(i64, @intCast(__koru_new_row)) };
}
};
pub const __store_apply_items_event = struct {
pub const Input = struct {
row: usize,
field: i64,
value_0: i64,
};
pub const Output = union(enum(u8)) {
v: i64,
};
pub fn handler(__koru_event_input: @This().Input) @This().Output {
// >>> PROC: __store_apply_items [tests/regression/600_STDLIB/690_STORE/690_252_phantom_borrow_crosses_into_a_query_arm/input.k:48]
const row = __koru_event_input.row;
const field = __koru_event_input.field;
const value_0 = __koru_event_input.value_0;
_ = &row;
_ = &field;
_ = &value_0;
_ = &__koru_event_input;
const __koru_r: usize = row;
return switch (field) {
0 => blk: { __koru_store_items.v[__koru_r] = value_0; break :blk .{ .v = value_0 }; },
else => unreachable,
};
}
};
pub const __store_sweepbody_items_L59_690_252_phantom_borrow_crosses_into_a_query_arm_input_6c3f0e_event = struct {
pub const Input = struct {
__koru_srf_e_L59_v: i64,
xs: *koru_std.koru_list.List_i64,
__koru_sdix_e_L59: usize,
};
pub const Output = void;
pub fn handler(__koru_event_input: @This().Input) @This().Output {
// >>> SUBFLOW: tests/regression/600_STDLIB/690_STORE/690_252_phantom_borrow_crosses_into_a_query_arm/input.k:58
const __koru_srf_e_L59_v = __koru_event_input.__koru_srf_e_L59_v;
const xs = __koru_event_input.xs;
const __koru_sdix_e_L59 = __koru_event_input.__koru_sdix_e_L59;
_ = &__koru_srf_e_L59_v;
_ = &xs;
_ = &__koru_sdix_e_L59;
_ = &__koru_event_input;
const result = koru_std.koru_list.push_i64_event.handler(.{ .xs = xs, .v = __koru_srf_e_L59_v });
_ = &result;
const n = koru_std.koru_list.len_i64_event.handler(.{ .xs = xs });
_ = &n;
(struct { fn __kout(__fd: i32, __b: []const u8) void { if (@import("builtin").os.tag == .freestanding) { const __kc = struct { extern var stdout: ?*anyopaque; extern var stderr: ?*anyopaque; extern fn fputs(__s: [*:0]const u8, __st: ?*anyopaque) c_int; }; var __kt: [4096]u8 = undefined; for (0..(__b.len + __kt.len - 2) / (__kt.len - 1)) |__ki| { const __kn = @min(__kt.len - 1, __b.len - __ki * (__kt.len - 1)); @memcpy(__kt[0..__kn], __b[__ki * (__kt.len - 1)..][0..__kn]); __kt[__kn] = 0; @import("std").mem.doNotOptimizeAway(__kc.fputs(@as([*:0]const u8, @ptrCast(&__kt)), if (__fd == 2) __kc.stderr else __kc.stdout)); } } else { @import("std").mem.doNotOptimizeAway(@import("std").posix.write(__fd, __b) catch @as(usize, 0)); } } fn __kw(comptime __f: []const u8, __a: anytype) void { var __kb: [65536]u8 = undefined; const __ks = @import("std").fmt.bufPrint(&__kb, __f, __a) catch __kb[0..0]; __kout(1, __ks); } }).__kw("pushed {d}, len {d}\n", .{__koru_srf_e_L59_v, n});
}
};
};
pub const koru_std = struct {
pub const koru_list = struct {
const std = @import("std");
const ast_find = @import("ast");
const facets = @import("ast_functional").facets;
pub const List_i64 = struct {
items: std.ArrayList(i64),
allocator: std.mem.Allocator,
fn deinit(self: *List_i64) void {
self.items.deinit(self.allocator);
self.allocator.destroy(self);
}
};
fn protoNameDbg(prog: *const astz.Program, elem: []const u8) bool {
if (findProtoDecl(prog, elem) != null) return true;
if (programHasProto(prog, elem)) return true;
return false;
}
fn protoEntryName(alloc: std.mem.Allocator, elem: []const u8) ?[]const u8 {
const trimmed = std.mem.trim(u8, elem, " \t");
if (trimmed.len == 0) return null;
const name = if (std.mem.lastIndexOfScalar(u8, trimmed, ':')) |ci|
std.mem.trim(u8, trimmed[ci + 1 ..], " \t")
else
trimmed;
if (name.len == 0) return null;
const primitives = [_][]const u8{ "i64", "i32", "i16", "i8", "u64", "u32", "u16", "u8", "f64", "f32", "bool", "usize", "string", "void", "char" };
for (primitives) |p| {
if (std.mem.eql(u8, name, p)) return null;
}
return alloc.dupe(u8, name) catch unreachable;
}
const ProtoFields = struct {
names: []const []const u8,
types: []const []const u8,
};
fn declEntryName(inv: *const ast_find.Invocation) []const u8 {
if (inv.args.len == 0) return "";
const a0 = inv.args[0];
if (a0.had_explicit_label) {
const label = std.mem.trim(u8, a0.name, " \t");
if (std.mem.endsWith(u8, label, "<"))
return std.mem.trim(u8, label[0 .. label.len - 1], " \t");
return label;
}
return inv.args[0].value;
}
fn protoParentSpec(inv: *const ast_find.Invocation) ?[]const u8 {
if (inv.args.len == 0) return null;
const a0 = inv.args[0];
if (!a0.had_explicit_label) return null;
const label = std.mem.trim(u8, a0.name, " \t");
if (!std.mem.endsWith(u8, label, "<")) return null;
const v = std.mem.trim(u8, a0.value, " \t");
return if (v.len > 0) v else null;
}
fn findProtoDecl(prog: *const ast_find.Program, elem: []const u8) ?*const ast_find.Flow {
const trimmed = std.mem.trim(u8, elem, " \t");
const want_name = if (std.mem.lastIndexOfScalar(u8, trimmed, ':')) |ci|
std.mem.trim(u8, trimmed[ci + 1 ..], " \t")
else
trimmed;
var want_mod: ?[]const u8 = null;
if (std.mem.lastIndexOfScalar(u8, trimmed, ':')) |ci| {
const qual = std.mem.trim(u8, trimmed[0..ci], " \t");
if (qual.len > 0) {
const dotted = std.mem.replaceOwned(u8, std.heap.page_allocator, qual, "/", ".") catch unreachable;
want_mod = dotted;
}
}
const Finder = struct {
fn invokesProto(f: *const ast_find.Flow, name: []const u8, mod: ?[]const u8) bool {
const inv = f.inv();
if (inv.path.segments.len != 1) return false;
const verb = inv.path.segments[0];
const mq = inv.path.module_qualifier orelse return false;
const types_door = std.mem.eql(u8, verb, "proto") and
(std.mem.eql(u8, mq, "std.types") or std.mem.eql(u8, mq, "std/types"));
const default_door = std.mem.eql(u8, verb, "default") and
(std.mem.eql(u8, mq, "std.proto") or std.mem.eql(u8, mq, "std/proto"));
if (!(types_door or default_door)) return false;
if (inv.args.len == 0) return false;
var nm = declEntryName(inv);
if (nm.len >= 2 and nm[0] == '"' and nm[nm.len - 1] == '"') nm = nm[1 .. nm.len - 1];
if (!std.mem.eql(u8, nm, name)) return false;
if (mod) |m| {
if (f.module.len > 0 and std.mem.eql(u8, f.module, m)) return true;
return false;
}
return true;
}
fn findIn(items: []const ast_find.Item, name: []const u8, mod: ?[]const u8) ?*const ast_find.Flow {
for (items) |pi| {
switch (pi) {
.flow => |*f| {
if (invokesProto(f, name, mod)) return f;
},
.module_decl => |*m| {
if (findIn(m.items, name, mod)) |hit| return hit;
},
else => {},
}
}
return null;
}
};
return Finder.findIn(prog.items, want_name, want_mod);
}
fn programHasProto(prog: *const ast_find.Program, elem: []const u8) bool {
if (findProtoDecl(prog, elem)) |_| return true;
const trimmed = std.mem.trim(u8, elem, " \t");
const want_name = if (std.mem.lastIndexOfScalar(u8, trimmed, ':')) |ci|
std.mem.trim(u8, trimmed[ci + 1 ..], " \t")
else
trimmed;
var want_mod: ?[]const u8 = null;
if (std.mem.lastIndexOfScalar(u8, trimmed, ':')) |ci| {
const qual = std.mem.trim(u8, trimmed[0..ci], " \t");
if (qual.len > 0) {
want_mod = std.mem.replaceOwned(u8, std.heap.page_allocator, qual, "/", ".") catch unreachable;
}
}
const Marker = struct {
fn matches(ic: *const ast_find.InlineCode, name: []const u8, mod: ?[]const u8) bool {
const prefix = "// proto ";
if (!std.mem.startsWith(u8, ic.code, prefix)) return false;
const colon = std.mem.indexOfScalar(u8, ic.code, ':') orelse return false;
if (!std.mem.eql(u8, std.mem.trim(u8, ic.code[prefix.len..colon], " \t"), name)) return false;
if (mod) |m| {
if (ic.module.len > 0 and std.mem.eql(u8, ic.module, m)) return true;
return false;
}
return true;
}
fn find(items: []const ast_find.Item, name: []const u8, mod: ?[]const u8) bool {
for (items) |pi| {
switch
... [truncated - 69KB total]Emitted C# source
static class main_module {
public static void __koru_stdout_write(dynamic s) => global::System.Console.Out.Write(s);
public static void __koru_stderr_write(dynamic s) => global::System.Console.Error.Write(s);
// The mutable handle carrier — `*String`-style resources are
// `new __KoruBox { data = … }` because C# anonymous types are
// read-only: `s.data = …` (std/string append/clear, handle
// mutation generally) needs a settable member.
public class __KoruBox { public dynamic data; }
// Textification for `{{ … }}` operands: C# bool ToStrings as
// `True` where Koru prints `true`, and the operand's static type
// is unknown at this boundary — a `(x) is bool` inline test would
// be a compile error on statically-typed operands instead. Generic
// on purpose: `dynamic` boxed every value-type operand — measured
// ~1s/10M elements on 012_threat_scanner — while T specializes to
// the operand's own ToString() with no box.
public static string __koru_str<T>(T v) => v is bool b ? (b ? "true" : "false") : v?.ToString();
// std/store: plural store 'items' created (SoA cell + insert/query/write/take/stripe units); fields v: i64
static class __koru_store_items {
public static long[] v = new long[8];
public static long len = 0;
public static long __koru_brand = -1;
}
public static class __store_inserth_items_event {
public struct Input {
public long v;
public long __site_line;
}
public struct Output {
public string tag;
public long row;
}
public static Output handler(Input __koru_input) {
var v = __koru_input.v;
var __site_line = __koru_input.__site_line;
if (__koru_store_items.len >= 8) throw new global::System.Exception("std/store: store 'items' is full (capacity 8) - declared capacity and the `| full` branch are pinned at 690_011");
long __koru_new_row = __koru_store_items.len;
__koru_store_items.v[__koru_new_row] = v;
__koru_store_items.len += 1;
return new Output { tag = "row", row = __koru_new_row };
return default;
}
}
public static class __store_apply_items_event {
public struct Input {
public long row;
public long field;
public long value_0;
}
public struct Output {
public string tag;
public long v;
}
public static Output handler(Input __koru_input) {
var row = __koru_input.row;
var field = __koru_input.field;
var value_0 = __koru_input.value_0;
var __koru_r = row;
switch (field) {
case 0: { __koru_store_items.v[__koru_r] = value_0; return new Output { tag = "v", v = value_0 }; }
}
throw new global::System.Exception("__store_apply_items: field index " + field + " is not a column of store 'items'");
return default;
}
}
public static class __store_sweepbody_items_L59_690_252_phantom_borrow_crosses_into_a_query_arm_input_6c3f0e_event {
public struct Input {
public long __koru_srf_e_L59_v;
public dynamic xs;
public long __koru_sdix_e_L59;
}
public static dynamic handler(Input __koru_input) {
var __koru_srf_e_L59_v = __koru_input.__koru_srf_e_L59_v;
var xs = __koru_input.xs;
var __koru_sdix_e_L59 = __koru_input.__koru_sdix_e_L59;
main_module.std_list_push_i64_event.handler(new std_list_push_i64_event.Input { xs = xs, v = (long)(__koru_srf_e_L59_v)});
var n = main_module.std_list_len_i64_event.handler(new std_list_len_i64_event.Input { xs = xs});
__koru_stdout_write("pushed " + __koru_str(__koru_srf_e_L59_v) + ", len " + __koru_str(n) + "\n");
return default;
}
}
public static class std_io_print_ln_event {
public struct Input {
public dynamic expr;
public dynamic invocation;
public dynamic item;
public dynamic program;
public dynamic reporter;
public dynamic allocator;
}
public static dynamic handler(Input __koru_input) {
var expr = __koru_input.expr;
var invocation = __koru_input.invocation;
var item = __koru_input.item;
var program = __koru_input.program;
var reporter = __koru_input.reporter;
var allocator = __koru_input.allocator;
throw new global::System.Exception("ln: [transform] tor is lowered at compile time and must never be called");
}
}
public static class std_list_new_i64_event {
public struct Input {
}
public static dynamic handler(dynamic __koru_input) {
throw new global::System.Exception("std.list:new-i64 has no C# implementation — its body resolves only to a non-cs target (|zig / [comptime]), directly or through a callee");
}
}
public static class std_list_free_i64_event {
public struct Input {
public dynamic xs;
}
public static dynamic handler(dynamic __koru_input) {
throw new global::System.Exception("std.list:free-i64 has no C# implementation — its body resolves only to a non-cs target (|zig / [comptime]), directly or through a callee");
}
}
public static void flow0() {
var result_0 = main_module.__store_inserth_items_event.handler(new __store_inserth_items_event.Input { v = (long)(10), __site_line = (long)(50)});
var _auto_6 = result_0.row;
}
public static void flow1() {
var result_1 = main_module.__store_inserth_items_event.handler(new __store_inserth_items_event.Input { v = (long)(20), __site_line = (long)(52)});
var _auto_7 = result_1.row;
}
public static void flow2() {
var result_2 = main_module.__store_inserth_items_event.handler(new __store_inserth_items_event.Input { v = (long)(30), __site_line = (long)(54)});
var _auto_8 = result_2.row;
}
public static void flow3() {
var result_3 = main_module.std_list_new_i64_event.handler(new std_list_new_i64_event.Input { });
if (result_3.tag == "list") {
var xs = result_3.list;
{
for (var __koru_si = 0; __koru_si < __koru_store_items.len; __koru_si++) {
var __koru_srf_e_L59_v = __koru_store_items.v[__koru_si];
main_module.__store_sweepbody_items_L59_690_252_phantom_borrow_crosses_into_a_query_arm_input_6c3f0e_event.handler(new main_module.__store_sweepbody_items_L59_690_252_phantom_borrow_crosses_into_a_query_arm_input_6c3f0e_event.Input { __koru_srf_e_L59_v = __koru_srf_e_L59_v, xs = xs, __koru_sdix_e_L59 = __koru_si });
}
}
main_module.std_list_free_i64_event.handler(new std_list_free_i64_event.Input { xs = xs});
}
if (result_3.tag == "err") {
var _auto_9 = result_3.err;
__koru_stdout_write("list failed" + "\n");
}
}
}
static class Program {
static void Main() {
main_module.flow0();
main_module.flow1();
main_module.flow2();
main_module.flow3();
}
}
Flows
flow ~new click a branch to expand · @labels scroll to their anchor
new (items, capacity: 8, source: v: i64)
flow ~insert click a branch to expand · @labels scroll to their anchor
insert (items, source: v: 10)
flow ~insert click a branch to expand · @labels scroll to their anchor
insert (items, source: v: 20)
flow ~insert click a branch to expand · @labels scroll to their anchor
insert (items, source: v: 30)
flow ~new-i64 click a branch to expand · @labels scroll to their anchor
new-i64
Test Configuration
MUST_RUN