✓
Passing This code compiles and runs correctly.
Code
// PINS: an effect branch's PAYLOAD TYPE is qualified when the consumer sits in
// a different module than the event.
//
// `pulse` declares `! tick *Beat`, and `Beat` belongs to app/lib/pulse. The
// consumer here is the main module, so the synthesized Handlers struct emits
//
// fn tick(b: *Beat) void { … }
//
// with the type written verbatim — and `Beat` is not in the consumer's scope:
//
// error: use of undeclared identifier 'Beat'
//
// The consumer is a SUBFLOW on purpose. A top-level consumer inlines the
// effectful call and never synthesizes a Handlers struct at all, so it dodges
// this; a subflow always synthesizes one and reaches it. That is also why every
// effect-branch test in the corpus passes — 400_105's `*Resource` is declared
// in the file that handles it, and the top-level sites inline.
//
// The payload's home is the module that DECLARES the event: that is where the
// author wrote the bare name and the only scope it ever resolved in.
//
// Found in koru-examples/downloads, where a `! sweep` arm calls curl's `poll`
// and its `! progress *Progress` / `! finished *Response` arms land in the
// app's module. Reproduced here with no curl.
import std/io
import app/lib/pulse
tor drive { k: i64 }
drive = app/lib/pulse:pulse(k)
! tick b |> std/io:print.ln("tick {{ b.n:d }}")
| done |> _
drive(k: 2)
Actual
tick 0
tick 1
Expected output
tick 0
tick 1
Flows
subflow ~drive click a branch to expand · @labels scroll to their anchor
pulse (k)
flow ~drive click a branch to expand · @labels scroll to their anchor
drive (k: 2)
Imported Files
// An effect branch whose payload is a POINTER TO A TYPE THIS MODULE OWNS.
// The consumer lives in another module, so the synthesized Handlers struct in
// the consumer's scope has to name `Beat` by its emitted host path — the
// consumer cannot see a bare `Beat`.
const std = @import("std");
pub const Beat = struct { n: i64 };
~pub tor pulse { k: i64 }
! tick *Beat
| done
~proc pulse|zig {
var i: i64 = 0;
while (i < k) : (i += 1) {
var b = $mod.Beat{ .n = i };
tick(&b);
}
return .{ .done = .{} };
}
Test Configuration
MUST_RUN