✓
Passing This code compiles and runs correctly.
Code
~import "$app/fs"
~pub event with_context {}
~proc with_context {
}
~app.fs:open(path: "test.txt")
| opened f |> with_context()
| scoped _[@scope] |> app.fs:close(file: f.file)
pub fn main() void {}
Error Verification
Expected Error Pattern
Test expects KORU032 error - @scope annotation should block discharge regardless of event nameActual Compiler Output
error[KORU021]: event 'input:with_context' has no branch 'scoped' (available: (none))
--> tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/330_054_scope_annotation_not_loop/input.kz:6:0
❌ Compiler coordination error: Incomplete branch coverage
error: CompilerCoordinationFailed
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/330_054_scope_annotation_not_loop/backend.zig:9442:17: 0x1005864af in emit (backend)
return error.CompilerCoordinationFailed;
^
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/330_054_scope_annotation_not_loop/backend.zig:9526:28: 0x1005872b7 in main (backend)
const generated_code = try RuntimeEmitter.emit(compile_allocator, final_ast);
^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 }
| opened *File[opened!]
~proc open {
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 .{ .opened = f };
}
// Close a file - CONSUMES opened! state (disposes the resource)
~pub event close { file: *File[!opened] }
~proc close {
std.debug.print("Closing file\n", .{});
}
Test Configuration
MUST_FAIL