✓
Passing This code compiles and runs correctly.
Code
// PIN: outermost resource discharged inside the INNER loop body.
// The obligation crosses two @scope boundaries (outer loop, inner loop).
// Discharging it in the innermost ! each is doubly wrong.
// Austral rule: "a linear value defined outside a loop cannot appear in the loop body."
//
// Grounding:
// Legal nested-for form: 330_032_nested_for_scopes/input.kz:3-9
// outermost_f is closed in the OUTER | done, not any each body
// for + each + done nesting syntax: 330_032_nested_for_scopes/input.kz:4-9
// KORU032 message: "Cannot discharge outer-scope resource inside @scope boundary"
import std/control
import app/fs
app/fs:open(path: "outermost.txt"): outermost_f |> for(0..2)
! each _ |> for(0..2)
! each _ |> app/fs:close(file: outermost_f) // ERROR: two @scope layers deep
| done |> _
| done |> _
Must contain:
KORU032Error Verification
Actual Compiler Output
error[KORU032]: Cannot discharge outer-scope resource 'outermost_f' inside @scope boundary. Handle outside the scope or escape via branch constructor.
--> auto_discharge:14:0
❌ Compiler coordination error: Auto-discharge failed (multiple disposal options or no disposal event)
error: CompilerCoordinationFailed
???:?:?: 0x102adf9d3 in _backend.RuntimeEmitter.emit (???)
???:?:?: 0x102ae0b63 in _backend.main (???)Flows
flow ~open click a branch to expand · @labels scroll to their anchor
open (path: "outermost.txt")
Imported Files
// Library module: fs
// Defines filesystem operations with cleanup obligations
const std = @import("std");
// File type with phantom states
const File = struct {
handle: i32,
};
// Open a file - returns opened! state (requires cleanup)
~pub event open { path: []const u8 } -> *File<opened!>
~proc open|zig {
std.debug.print("Opening file: {s}\n", .{path});
const allocator = std.heap.page_allocator;
const f = allocator.create(File) catch unreachable;
f.* = File{ .handle = 42 };
return f;
}
// Close a file - CONSUMES opened! state (disposes the resource)
~pub event close { file: *File<!opened> }
~proc close|zig {
std.debug.print("Closing file\n", .{});
}
Test Configuration
MUST_FAIL