Files
aji/tests/conformance/phase2/run/outside_scope.air
T
dev d405d4ea50 Phase 2: I/O intrinsics, linear resources, deterministic profile (RFC 0007)
- air: resource types file<read|write|append>, listener, stream; io_error;
  intrinsic registry (19 intrinsics) synced with reference/intrinsics.md;
  fallible intrinsics as ok/err terminators; fs prefix narrowing;
  linear_aggregates gating
- verifier: intrinsic form, operand, result and capability-kind checks
  (E1001, E3201, E5002); intrinsic effects (E3101); resource linearity
  in the borrow walker with per-edge moves: E3002 leaks and join
  mismatches, E3001, E2001, E2002, E2101 for close while borrowed;
  resources as borrow roots
- interp: deterministic world (captured console, VFS, loopback TCP,
  instruction clock, pinned xoshiro256 PRNG), blocked outcome, run
  record with stdout/stderr/files
- CLI: --stdin, --vfs, --seed, --result-file, --profile (hosted: exit 3),
  exit code 7; runner: stdin/vfs/seed/stdout/stderr/file/blocked headers
- conformance: hello, file copy and TCP echo exit programs; 37 new tests;
  4000 mutants without a crash
2026-10-04 14:02:17 +03:00

90 lines
2.2 KiB
LLVM

; A path outside the capability scope is permission_denied.
; expect: run
; grant: src=fs.read:/data
; vfs: /etc/passwd=root
; result: 1
; phase: 2
; spec: docs/reference/intrinsics.md
module test.outside_scope
air 0
lang 0.1
features [arrays, capabilities, effects, ownership, resources]
fn @main(%src: cap<fs.read>) -> u8
effects [fs.read]
entry:
%p = local.alloc array<u8, 11>
local.zero %p
%p_m = borrow.mut %p
%p_i0 = const.usize 0
%p_c0 = const.u8 47
%p_e0 = borrow.index %p_m, %p_i0
store %p_e0, %p_c0
borrow.end %p_e0
%p_i1 = const.usize 1
%p_c1 = const.u8 101
%p_e1 = borrow.index %p_m, %p_i1
store %p_e1, %p_c1
borrow.end %p_e1
%p_i2 = const.usize 2
%p_c2 = const.u8 116
%p_e2 = borrow.index %p_m, %p_i2
store %p_e2, %p_c2
borrow.end %p_e2
%p_i3 = const.usize 3
%p_c3 = const.u8 99
%p_e3 = borrow.index %p_m, %p_i3
store %p_e3, %p_c3
borrow.end %p_e3
%p_i4 = const.usize 4
%p_c4 = const.u8 47
%p_e4 = borrow.index %p_m, %p_i4
store %p_e4, %p_c4
borrow.end %p_e4
%p_i5 = const.usize 5
%p_c5 = const.u8 112
%p_e5 = borrow.index %p_m, %p_i5
store %p_e5, %p_c5
borrow.end %p_e5
%p_i6 = const.usize 6
%p_c6 = const.u8 97
%p_e6 = borrow.index %p_m, %p_i6
store %p_e6, %p_c6
borrow.end %p_e6
%p_i7 = const.usize 7
%p_c7 = const.u8 115
%p_e7 = borrow.index %p_m, %p_i7
store %p_e7, %p_c7
borrow.end %p_e7
%p_i8 = const.usize 8
%p_c8 = const.u8 115
%p_e8 = borrow.index %p_m, %p_i8
store %p_e8, %p_c8
borrow.end %p_e8
%p_i9 = const.usize 9
%p_c9 = const.u8 119
%p_e9 = borrow.index %p_m, %p_i9
store %p_e9, %p_c9
borrow.end %p_e9
%p_i10 = const.usize 10
%p_c10 = const.u8 100
%p_e10 = borrow.index %p_m, %p_i10
store %p_e10, %p_c10
borrow.end %p_e10
borrow.end %p_m
%p_r = borrow.ref %p
%p_s = slice.make %p_r
intrinsic fs.open_read(%src, %p_s), ok -> @opened, err -> @failed
opened(%f: file<read>):
trap
failed(%e: io_error):
borrow.end %p_s
borrow.end %p_r
enum.switch io_error %e, permission_denied -> @denied, default -> @other()
denied:
%one = const.u8 1
ret %one
other:
%two = const.u8 2
ret %two