✓
Passing This code compiles and runs correctly.
Code
// Negative: a bare phantom state referenced OUTSIDE its declaring module does
// NOT unify with the foreign state — it self-resolves to a DIFFERENT state and
// is caught as an ordinary phantom-state mismatch (the ratified self-resolution
// model — no special "reject bare-outside" mechanism is needed).
//
// Rule: a bare phantom self-resolves to its BASE TYPE's module; a primitive base
// (`string`) has no module, so it resolves to the WRITING module. So bare
// `<!secret>` written here in module `input` means `input:secret` — `input`'s
// own (distinct) state — NOT app/lib/store's `secret`. `input:secret` and
// `app.lib.store:secret` are genuinely different states, so consuming the former
// from a value holding the latter is a plain KORU030 mismatch. To reach
// app/lib/store's state you must qualify it (contrast 330_087:
// `<app/lib/store:!secret>`).
~import std/io
~import app/lib/store
// BARE <!secret> in a USER module — outside app/lib/store. `secret` is
// app/lib/store's state, referenced here with no module qualifier on a
// module-less base type (`string`). Its home cannot be inferred, so this must
// be REJECTED (contrast 330_087, which qualifies it: `<app/lib/store:!secret>`).
~tor use-secret { s: string<!secret> } -> string
~proc use-secret|zig {
return s;
}
~app/lib/store:make-secret(payload: "shh"): s |> use-secret(s): _ |> std/io:print.ln("ok")
Must fail at runtime with:
CONTAINS error[KORU030]
CONTAINS Phantom state mismatchFlows
flow ~make-secret click a branch to expand · @labels scroll to their anchor
make-secret (payload: "shh")
Imported Files
// A module that ISSUES a phantom-tagged scalar obligation, for the cross-module
// unification tests (330_087, 330_088, 330_089).
//
// `secret` is a compile-time taint tag: `make-secret` issues `<secret!>` (an
// obligation that the value must be `reveal`-ed before use); `reveal` consumes
// `<!secret>` and returns a plain value. This is the minimal taint-tracking
// vocabulary — a module that declares a phantom-state vocabulary carried on a
// builtin scalar (no home module of its own), which is exactly why the state
// must name its own module rather than being implied by the type.
const std = @import("std");
~pub tor make-secret { payload: string } -> string<secret!>
~proc make-secret|zig {
return payload;
}
// Consume the secret obligation: discharges <secret!> -> a plain value.
~pub tor reveal { s: string<!secret> } -> string
~proc reveal|zig {
return s;
}