✓
Passing Passing: the compiler rejects this program as expected.
Code
// `&name` borrows a binding's storage. A binding without `[mutable]` emits
// `const`, so its `&` is `*const` and can never reach a `*T` parameter.
// Pin: the refusal is a pipeline diagnostic naming the param and the
// annotation to add — not a Zig const-discard failure on emitted code.
// The annotated spelling (020_007) stays the control.
const std = @import("std");
~tor get-data {} -> i32
~proc get-data|zig {
return 42;
}
~tor mutate-and-print { ptr: *i32 }
~proc mutate-and-print|zig {
ptr.* += 1;
std.debug.print("Value: {d}\n", .{ptr.*});
}
~get-data(): r |> mutate-and-print(ptr: &r)
Actual compiler output
error[KORU107]: '&r' borrows immutable binding 'r' into mutable parameter 'ptr' (*i32)
--> tests/regression/500_INTEGRATION_TESTING/510_NEGATIVE_TESTS/510_128_ampersand_borrow_requires_mutable/input.kz:21:1
|
21 | ~get-data(): r |> mutate-and-print(ptr: &r)
| ^
hint: annotate 'r[mutable]' at the bind site to lend it mutablyFrontend must reject with:
CONTAINS error[KORU107]
CONTAINS borrows immutable binding 'r' into mutable parameter 'ptr'
CONTAINS 'r[mutable]'Flows
flow ~get-data click a branch to expand · @labels scroll to their anchor
get-data
Test Configuration
MUST_ERROR