✓
Passing This code compiles and runs correctly.
Code
// PINS: settling ONE of two obligations issued by one exit is not settling
// both. `open-two` hands back `file1` and `file2`, each owing <opened!>;
// closing `file1` alone must be refused, naming the field still owed.
~import app/fs
~app/fs:open-two(path1: "test1.txt", path2: "test2.txt"): f |> app/fs:close(file: f.file1)
Must contain:
error[KORU030]Flows
flow ~open-two click a branch to expand · @labels scroll to their anchor
open-two (path1: "test1.txt", path2: "test2.txt")
Imported Files
// Two obligations issued by ONE exit. `close` settles exactly one of them, so
// a consumer that calls it once still owes the other.
//
// The record bare return (`-> { a: T, b: T }`) is the shape that carries two
// phantom-bearing fields out of a single exit; a lone payload-carrying branch
// is refused at the declaration by PARSE003 ("declare the single output as a
// bare return instead").
const std = @import("std");
const File = struct { handle: i32 };
~pub tor open-two { path1: string, path2: string } -> { file1: *File<opened!>, file2: *File<opened!> }
~proc open-two|zig {
std.debug.print("Opening two files: {s}, {s}\n", .{path1, path2});
const allocator = std.heap.page_allocator;
const f1 = allocator.create(File) catch unreachable;
const f2 = allocator.create(File) catch unreachable;
f1.* = File{ .handle = 42 };
f2.* = File{ .handle = 43 };
return .{ .file1 = f1, .file2 = f2 };
}
~pub tor close { file: *File<!opened> }
~proc close|zig {
std.debug.print("Closing file\n", .{});
}