✓
Passing This code compiles and runs correctly.
Code
import app/host
import std/io
app/host:box.make(): b
|> app/host:box.tag(b): _
|> std/io:print.ln("ok")
|> app/host:box.drop(b)
Supporting Files
const std = @import("std");
~import app/lib
// A host-language struct decl carrying a cross-module field type. The
// structured parse turns `inner`'s `?*app/lib:Widget` into
// module_path + base, writeFieldType emits
// `?*koru_app.koru_lib.Widget`, and the field's module_path feeds the
// type-home backfill — pulling app/lib into emission even though no
// implemented tor signature names it.
pub const Box = struct {
inner: ?*app/lib:Widget,
tag: u32,
};
~pub tor box.make {} -> *Box<live!>
~proc box.make|zig {
const b = std.heap.page_allocator.create(Box) catch unreachable;
b.* = .{ .inner = null, .tag = 7 };
return b;
}
~pub tor box.tag { b: *Box<live> } -> u32
~proc box.tag|zig {
return b.tag;
}
~pub tor box.drop { b: *Box<!live> }
~proc box.drop|zig {
std.heap.page_allocator.destroy(b);
}
const std = @import("std");
// A type whose module is referenced ONLY from a host struct field in
// host.kz — never from a tor signature. Module emission is lazy-by-
// reference; if the `app/lib:Widget` field's module_path does not reach
// the type-home backfill, `koru_app.koru_lib` never emits and the
// backend Zig fails `has no member named 'koru_lib'`.
pub const Widget = struct {
name: []const u8,
};
Actual
ok
Expected output
ok
Flows
flow ~box.make click a branch to expand · @labels scroll to their anchor
box.make
Test Configuration
MUST_RUN