Phase 2: unsafe operations and trusted boundaries (RFC 0009)
- air: string literals (trusted line only), trusted obligation on functions, assume, borrow.index.unchecked - verifier: unsafe stage (E6001 outside_boundary / trusted_declares_unsafe); effect stage leaves unsafe to it, so trusted functions discharge it; assume establishes bounds facts - interp: T0009 for detected unsafe precondition violations - aji check --report unsafe: trusted functions with obligations, unsafe functions, unsafe operations with their boundary - feature unsafe published and supported; 10 conformance tests; 3000 mutants without a crash
This commit is contained in:
1 parent
c510a37cf9
commit
008654999e
24 files changed
+422
-18
No files matched your search
+10
-1
@@ -17,7 +17,9 @@ const usage =
|
||||
\\usage: aji <command> [args]
|
||||
\\
|
||||
\\commands:
|
||||
\\ check <file.air> parse and verify a text AIR module
|
||||
\\ check [--report unsafe] <file.air>
|
||||
\\ parse and verify a text AIR module; the unsafe report
|
||||
\\ lists trusted boundaries and unsafe operations
|
||||
\\ run [--fuel N] [--grant P=KIND[:SCOPE]]... <file.air>
|
||||
\\ verify, then run @main and print the run record;
|
||||
\\ --fuel stops after N executed instructions;
|
||||
@@ -87,6 +89,12 @@ fn run(io: std.Io, arena: std.mem.Allocator, args: []const [:0]const u8, out: *s
|
||||
var files: std.ArrayList(struct { []const u8, []const u8 }) = .empty;
|
||||
var result_file: ?[]const u8 = null;
|
||||
var rest = args[2..];
|
||||
var unsafe_report = false;
|
||||
if (std.mem.eql(u8, cmd, "check") and rest.len == 3 and std.mem.eql(u8, rest[0], "--report")) {
|
||||
if (!std.mem.eql(u8, rest[1], "unsafe")) return usageError("--report takes unsafe");
|
||||
unsafe_report = true;
|
||||
rest = rest[2..];
|
||||
}
|
||||
while (std.mem.eql(u8, cmd, "run") and rest.len >= 3) {
|
||||
const flag = rest[0];
|
||||
const value = rest[1];
|
||||
@@ -125,6 +133,7 @@ fn run(io: std.Io, arena: std.mem.Allocator, args: []const [:0]const u8, out: *s
|
||||
try d.writeJson(out);
|
||||
try out.writeByte('\n');
|
||||
}
|
||||
if (unsafe_report) if (report.module) |module| try aji.verifier.unsafe_.writeReport(module, out);
|
||||
if (report.status == .accepted and std.mem.eql(u8, cmd, "run")) {
|
||||
const module = report.module.?;
|
||||
var output: aji.interp.Output = undefined;
|
||||
|
||||
Reference in new issue
Block a user