✓
Passing This code compiles and runs correctly.
Code
// TEST: Label jump inside @scope must not drop INNER obligations
// STATUS: MUST_FAIL (KORU030)
//
// The resource is created inside @scope and then a label jump occurs.
// This should be rejected because the inner obligation is dropped.
const std = @import("std");
const Resource = struct { id: i32 };
~event create {}
| created { res: *Resource[open!] }
~proc create {
const r = std.heap.page_allocator.create(Resource) catch unreachable;
r.* = .{ .id = 2 };
return .{ .created = .{ .res = r } };
}
~event close { res: *Resource[!open] }
| closed {}
~proc close {
std.heap.page_allocator.destroy(res);
return .{ .closed = .{} };
}
~pub event with_context {}
| scoped {}
| done {}
~proc with_context {
return .{ .scoped = .{} };
}
~#loop create()
| created c |> with_context()
| scoped _[@scope] |> create()
| created _inner |> @loop()
| done |> close(res: c.res)
| closed |> _
pub fn main() void {}
Error Verification
Actual Compiler Output
Segmentation fault at address 0x5
???:?:?: 0x19ba2d410 in ??? (libsystem_platform.dylib)
/Users/larsde/src/koru/src/phantom_semantic_checker.zig:1449:82: 0x104f3f8b3 in validateContinuation (backend)
var disposal_events = try self.findDisposalEventsForState(phantom_state);
^
/Users/larsde/src/koru/src/phantom_semantic_checker.zig:1030:83: 0x104f3be3b in validateContinuation (backend)
const nested_valid = try self.validateContinuation(nested, step_event_info.decl, step_module, flow_module, event_map, location, &void_chain_context, implementing_event);
^
/Users/larsde/src/koru/src/phantom_semantic_checker.zig:1577:75: 0x104f40df3 in validateContinuation (backend)
const nested_valid = try self.validateContinuation(nested, event_decl, event_module, flow_module, event_map, location, &context, implementing_event);
^
/Users/larsde/src/koru/src/phantom_semantic_checker.zig:1545:71: 0x104f40a7b in validateContinuation (backend)
const nested_valid = try self.validateContinuation(nested, nested_event_info.decl, module_name, flow_module, event_map, location, &context, implementing_event);
^
/Users/larsde/src/koru/src/phantom_semantic_checker.zig:1545:71: 0x104f40a7b in validateContinuation (backend)
const nested_valid = try self.validateContinuation(nested, nested_event_info.decl, module_name, flow_module, event_map, location, &context, implementing_event);
^
/Users/larsde/src/koru/src/phantom_semantic_checker.zig:901:61: 0x104f3a6bf in validateFlow (backend)
const cont_valid = try self.validateContinuation(cont_ptr, event_info.decl, module_name, current_module, event_map, flow.location, null, implementing_event);
^
/Users/larsde/src/koru/src/phantom_semantic_checker.zig:794:51: 0x104f4116f in validateItems (backend)
if (!try self.validateFlow(flow, event_map, module, null)) {
^
/Users/larsde/src/koru/src/phantom_semantic_checker.zig:756:34: 0x104f41823 in validatePhantomFlows (backend)
return self.validateItems(source_ast.items, &event_map, null);
^
/Users/larsde/src/koru/src/phantom_semantic_checker.zig:78:58: 0x104f41e77 in check (backend)
const flows_valid = try self.validatePhantomFlows(source_ast);
^
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/370_PHANTOM_TYPES/370_022_label_jump_scope_inner_must_fail/backend_output_emitted.zig:1955:34: 0x104edea77 in handler (backend)
checker.check(mutable_ctx.ast) catch |err| {
^
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/370_PHANTOM_TYPES/370_022_label_jump_scope_inner_must_fail/backend_output_emitted.zig:843:119: 0x104ecaa0f in handler (backend)
const nested_result_2 = koru_std.compiler.check_phantom_semantic_event.handler(.{ .ctx = c3 });
^
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/370_PHANTOM_TYPES/370_022_label_jump_scope_inner_must_fail/backend_output_emitted.zig:663:97: 0x104eba58f in handler (backend)
const nested_result_1 = koru_std.compiler.analysis_event.handler(.{ .ctx = c1 });
^
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/370_PHANTOM_TYPES/370_022_label_jump_scope_inner_must_fail/backend.zig:9504:81: 0x104eba363 in emit (backend)
const result = backend_output.koru_std.compiler.coordinate_event.handler(.{ .program_ast = source_ast, .allocator = allocator });
^
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/370_PHANTOM_TYPES/370_022_label_jump_scope_inner_must_fail/backend.zig:9598:51: 0x104ebaf7f in main (backend)
const generated_code = try RuntimeEmitter.emit(compile_allocator, final_ast);
^
/opt/homebrew/Cellar/zig/0.15.1/lib/zig/std/start.zig:627:37: 0x104ec2553 in main (backend)
const result = root.main() catch |err| {
^
???:?:?: 0x19b659d53 in ??? (???)
???:?:?: 0x0 in ??? (???)
/Users/larsde/src/koru/scripts/regression_lib.sh: line 33: 31670 Abort trap: 6 ./backend outputTest Configuration
MUST_FAIL