Files
aji/tests/conformance/phase2/run/echo_stdin.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

38 lines
886 B
LLVM

; stdin is read from the run inputs and echoed to stdout.
; expect: run
; grant: in=io.read
; grant: out=io.write
; stdin: echo me
; result: null
; stdout: echo me
; phase: 2
; spec: docs/reference/intrinsics.md
module test.echo_stdin
air 0
lang 0.1
features [arrays, capabilities, effects, ownership, resources]
fn @main(%in: cap<io.read>, %out: cap<io.write>) -> void
effects [io.read, io.write]
entry:
%b = local.alloc array<u8, 16>
local.zero %b
%m = borrow.mut %b
%s = slice.make %m
intrinsic io.stdin_read(%in, %s), ok -> @got, err -> @fail
got(%n: usize):
%z = const.usize 0
%part = slice.sub %s, %z, %n
%pr = borrow.ref %part
intrinsic io.stdout_write(%out, %pr), ok -> @done, err -> @fail2
done:
borrow.end %pr
borrow.end %part
borrow.end %s
borrow.end %m
ret
fail(%e: io_error):
trap
fail2(%e2: io_error):
trap