Files
sx/examples/errors/1058-errors-reexport-value-failable-channel.sx
agra 66bdc70bf1 test: group examples into per-category folders
Move examples/*.sx and their expected/ snapshots into per-category
subfolders (examples/<category>/...). Folder = leading filename token,
with ffi-objc/ffi-jni kept whole; filenames are unchanged. The corpus
runner and LSP sweep now discover each category's expected/ dir, while
issues/ stays flat. Example 1058's repo-root-relative companion import
is made file-relative. Path strings embedded in 164 snapshots were
regenerated (path-only changes). Test-layout docs in CLAUDE.md updated.
2026-06-21 14:41:34 +03:00

24 lines
1.0 KiB
Plaintext

// A generic value-failable fn `($R, !E)` reached through a RE-EXPORT alias
// keeps its `!` error channel at the call site — the result types as a
// value-failable, so `or` / `try` accept it. Mirrors std.sx's
// `await :: io_mod.await` (+ `IoErr :: io_mod.IoErr`) re-export.
// Regression (issue 0153): the planned call-result type was resolved in the
// CALL-SITE module (where `LE` is a re-export alias → a non-`.error_set`
// TypeId), so `errorChannelOf` saw a plain tuple and `b.get() or {…}` built a
// malformed i1 PHI. The fix pins return-type resolution to the fn's defining
// module, matching `monomorphizeFunction`. Needs BOTH generic + re-export.
#import "modules/std.sx";
lib :: #import "1058-errors-reexport-value-failable-channel/lib.sx";
// Re-export the generic fn AND its error set (the std.sx facade pattern).
Box :: lib.Box;
get :: lib.get;
LE :: lib.LE;
main :: () -> i32 {
b : Box(i64) = .{ v = 42 };
r := b.get() or { -1 }; // value-failable channel preserved → r=42
print("r={}\n", r);
return 0;
}