✓
Passing This code compiles and runs correctly.
Code
import std/control
import app/fs
for(0..2)
! each _ |> app/fs:open(path: "outer.txt"): of |> for(0..2)
! each _ |> app/fs:open(path: "inner.txt"): inf
| done |> _
| done |> _
Actual
Opening: outer.txt
Opening: inner.txt
Closing
Opening: inner.txt
Closing
Closing
Opening: outer.txt
Opening: inner.txt
Closing
Opening: inner.txt
Closing
Closing
Expected output
Opening: outer.txt
Opening: inner.txt
Closing
Opening: inner.txt
Closing
Closing
Opening: outer.txt
Opening: inner.txt
Closing
Opening: inner.txt
Closing
Closing
Flows
flow ~for click a branch to expand · @labels scroll to their anchor
for (0..2)
Imported Files
// Library module: fs
// Single disposal event
const std = @import("std");
const File = struct { handle: i32 };
// Open a file - returns opened! state (requires cleanup)
~pub tor open { path: string } -> *File<opened!>
~proc open|zig {
std.debug.print("Opening: {s}\n", .{path});
const f = std.heap.page_allocator.create(File) catch unreachable;
f.* = File{ .handle = 42 };
return f;
}
// Close - the ONLY consumer of <!opened>
~pub tor close { file: *File<!opened> }
~proc close|zig {
std.debug.print("Closing\n", .{});
}
Test Configuration
MUST_RUN