cli: add explicit package source modules
Link manifest-selected source graphs with module-local names, qualified structs/enums/functions and task workers through ordinary AIR verification. Keep source inputs bounded, reject source symlinks and preserve explicit grants, diagnostics and deterministic canonical lowering. Integrate spec 12/15, RFC 0021, source reference budgets, roadmap, examples and CI coverage. Validate 579 conformance tests, unit tests, 76 source constructs, hosted smoke, 36 package CLI checks and task schedule stress.
This commit is contained in:
81 files changed
+1419
-234
No files matched your search
@@ -0,0 +1,7 @@
|
||||
// expect: reject E2101 E2101
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// module: app.borrow=source/modules/borrow.aji.inc
|
||||
module app.entry
|
||||
import app.borrow;
|
||||
fn main() -> u8 effects [] { var data: [u8; 4] = zero; ref held = data; app.borrow.fill(mut data); return held[0]; }
|
||||
@@ -0,0 +1,2 @@
|
||||
module app.bad
|
||||
fn nope() -> u8 effects [] { return missing(); }
|
||||
@@ -0,0 +1,2 @@
|
||||
module app.broken
|
||||
fn nope(
|
||||
@@ -0,0 +1,8 @@
|
||||
// expect: run
|
||||
// result: 42
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// module: app.borrow=source/modules/borrow.aji.inc
|
||||
module app.entry
|
||||
import app.borrow;
|
||||
fn main() -> u8 effects [] { var data: [u8; 4] = zero; app.borrow.fill(mut data); return data[3]; }
|
||||
@@ -0,0 +1,2 @@
|
||||
module app.borrow
|
||||
fn fill(dst: slice_mut<u8>) -> void effects [] { for i in 0..dst.len { dst[i] = 42; } }
|
||||
@@ -0,0 +1,14 @@
|
||||
// expect: run
|
||||
// result: 42
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// module: app.model=source/modules/model.aji.inc
|
||||
module app.entry
|
||||
import app.model;
|
||||
struct __aji_app_model_Pair { own_value: u64 }
|
||||
fn __aji_app_model_total() -> u64 effects [] { return 7; }
|
||||
fn main() -> u64 effects [] {
|
||||
assert(__aji_app_model_total() == 7);
|
||||
let pair = app.model.Pair { right: 22, left: 20 };
|
||||
return app.model.total(pair);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// expect: reject E7006
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// module: app.a=source/modules/cycle_a.aji.inc
|
||||
// module: app.b=source/modules/cycle_b.aji.inc
|
||||
module app.entry
|
||||
import app.a;
|
||||
fn main() -> u64 effects [] { return 42; }
|
||||
@@ -0,0 +1,3 @@
|
||||
module app.a
|
||||
import app.b;
|
||||
fn value() -> u8 effects [] { return 1; }
|
||||
@@ -0,0 +1,2 @@
|
||||
module app.b
|
||||
import app.a;
|
||||
@@ -0,0 +1,8 @@
|
||||
// expect: reject E7006
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// module: app.model=source/modules/model.aji.inc
|
||||
// module: app.model=source/modules/model.aji.inc
|
||||
module app.entry
|
||||
import app.model;
|
||||
fn main() -> u64 effects [] { return 42; }
|
||||
@@ -0,0 +1,8 @@
|
||||
// expect: reject E7006
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// module: app.model=source/modules/model.aji.inc
|
||||
module app.entry
|
||||
import app.model;
|
||||
import app.model;
|
||||
fn main() -> u64 effects [] { return 42; }
|
||||
@@ -0,0 +1,7 @@
|
||||
// expect: reject E7006
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// module: app.duplicate=source/modules/duplicate_member.aji.inc
|
||||
module app.entry
|
||||
import app.duplicate;
|
||||
fn main() -> u64 effects [] { return 42; }
|
||||
@@ -0,0 +1,3 @@
|
||||
module app.duplicate
|
||||
fn member() -> u64 effects [] { return 1; }
|
||||
fn member() -> u64 effects [] { return 2; }
|
||||
@@ -0,0 +1,2 @@
|
||||
module app.effect
|
||||
fn emit(out: cap<io.write>) -> void effects [io.write] { io.stdout_write(out, b"module") or trap; }
|
||||
@@ -0,0 +1,10 @@
|
||||
// expect: run
|
||||
// result: 42
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// grant: out=io.write
|
||||
// stdout: module
|
||||
// module: app.effect=source/modules/effect.aji.inc
|
||||
module app.entry
|
||||
import app.effect;
|
||||
fn main(out: cap<io.write>) -> u64 effects [io.write] { app.effect.emit(out); return 42; }
|
||||
@@ -0,0 +1,7 @@
|
||||
// expect: reject E7002
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// module: app.bad=source/modules/bad_member.aji.inc
|
||||
module app.entry
|
||||
import app.bad;
|
||||
fn main() -> u64 effects [] { return 42; }
|
||||
@@ -0,0 +1,14 @@
|
||||
// expect: run
|
||||
// result: 42
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// module: app.model=source/modules/example_model.aji.inc
|
||||
module app.entry
|
||||
import app.model;
|
||||
|
||||
fn main() -> u64
|
||||
effects []
|
||||
{
|
||||
let pair = app.model.Pair { left: 20, right: 22 };
|
||||
return app.model.total(pair);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
module app.model
|
||||
|
||||
struct Pair { left: u64, right: u64 }
|
||||
|
||||
fn total(pair: Pair) -> u64
|
||||
effects []
|
||||
{ return pair.left + pair.right; }
|
||||
@@ -0,0 +1,14 @@
|
||||
// expect: run
|
||||
// result: 42
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// module: app.fields=source/modules/fields.aji.inc
|
||||
module app.entry
|
||||
import app.fields;
|
||||
fn main() -> u64 effects [] {
|
||||
var pair: app.fields.Pair = app.fields.Pair { left: 19, right: 22 };
|
||||
app.fields.increment(mut pair);
|
||||
let wrapper = app.fields.Wrap { pair: pair };
|
||||
let value: app.fields.Pair = app.fields.unwrap(wrapper);
|
||||
return app.fields.total(ref value);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
module app.fields
|
||||
struct Pair { left: u64, right: u64 }
|
||||
struct Wrap { pair: Pair }
|
||||
fn increment(pair: mut<Pair>) -> void effects [] { pair.left = pair.left + 1; }
|
||||
fn total(pair: ref<Pair>) -> u64 effects [] { return pair.left + pair.right; }
|
||||
fn unwrap(value: Wrap) -> Pair effects [] { return value.pair; }
|
||||
@@ -0,0 +1,7 @@
|
||||
// expect: reject E7006
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// module: app.other=source/modules/model.aji.inc
|
||||
module app.entry
|
||||
import app.other;
|
||||
fn main() -> u64 effects [] { return 42; }
|
||||
@@ -0,0 +1,7 @@
|
||||
// expect: reject E3101
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// module: app.effect=source/modules/effect.aji.inc
|
||||
module app.entry
|
||||
import app.effect;
|
||||
fn main(out: cap<io.write>) -> u64 effects [] { app.effect.emit(out); return 42; }
|
||||
@@ -0,0 +1,7 @@
|
||||
// expect: reject E7006
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// module: app.model=source/modules/model.aji.inc
|
||||
module app.entry
|
||||
import app.model;
|
||||
fn main() -> u64 effects [] { let pair = app.model.Pair { left: 20 }; return pair.left; }
|
||||
@@ -0,0 +1,6 @@
|
||||
// expect: reject E7002
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
module app.entry
|
||||
import app.unknown;
|
||||
fn main() -> u64 effects [] { return 42; }
|
||||
@@ -0,0 +1,7 @@
|
||||
// expect: reject E7003
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// module: app.owner=source/modules/owner.aji.inc
|
||||
module app.entry
|
||||
import app.owner;
|
||||
fn main(mem: cap<mem.alloc>) -> u64 effects [mem.alloc] { let value = own.new(42u64, mem) or trap; app.owner.dispose(value); return 42; }
|
||||
@@ -0,0 +1,9 @@
|
||||
module app.model
|
||||
struct Pair { left: u64, right: u64 }
|
||||
struct Wrap { pair: Pair }
|
||||
enum State { Done(Pair), Empty }
|
||||
fn make() -> Pair effects [] { return Pair { left: 20, right: 22 }; }
|
||||
fn total(pair: Pair) -> u64 effects [] { return pair.left + pair.right; }
|
||||
fn helper() -> u64 effects [] { return 10; }
|
||||
fn local() -> u64 effects [] { return helper(); }
|
||||
fn main() -> u64 effects [] { return 9; }
|
||||
@@ -0,0 +1,7 @@
|
||||
// expect: reject E7002
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// module: app.model=source/modules/model.aji.inc
|
||||
module app.entry
|
||||
import app.model;
|
||||
fn main() -> u64 effects [] { let pair = Pair { left: 20, right: 22 }; return pair.left; }
|
||||
@@ -0,0 +1,9 @@
|
||||
// expect: reject E7005
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// module: app.model=source/modules/model.aji.inc
|
||||
// module: app.other=source/modules/other.aji.inc
|
||||
module app.entry
|
||||
import app.model;
|
||||
import app.other;
|
||||
fn main() -> u64 effects [] { let pair: app.model.Pair = app.other.make(); return pair.left; }
|
||||
@@ -0,0 +1,3 @@
|
||||
module app.other
|
||||
struct Pair { left: u64, right: u64 }
|
||||
fn make() -> Pair effects [] { return Pair { left: 20, right: 22 }; }
|
||||
@@ -0,0 +1,9 @@
|
||||
// expect: run
|
||||
// result: 42
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// grant: mem=mem.alloc:128
|
||||
// module: app.owner=source/modules/owner.aji.inc
|
||||
module app.entry
|
||||
import app.owner;
|
||||
fn main(mem: cap<mem.alloc>) -> u64 effects [mem.alloc] { let value = own.new(42u64, mem) or trap; app.owner.dispose(move value); return 42; }
|
||||
@@ -0,0 +1,2 @@
|
||||
module app.owner
|
||||
fn dispose(value: own<u64>) -> void effects [] { own.free(move value); }
|
||||
@@ -0,0 +1,22 @@
|
||||
// expect: run
|
||||
// result: 42
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// equivalent: modules/record.air
|
||||
// module: app.work=source/modules/work.aji.inc
|
||||
// module: app.model=source/modules/model.aji.inc
|
||||
module app.entry
|
||||
import app.model;
|
||||
import app.work;
|
||||
fn helper() -> u64 effects [] { return 100; }
|
||||
fn main() -> u64 effects [] {
|
||||
let app = 7u8;
|
||||
assert(app == 7);
|
||||
assert(helper() == 100);
|
||||
assert(app.model.local() == 10);
|
||||
assert(app.model.main() == 9);
|
||||
let p: app.model.Pair = app.work.run();
|
||||
let w = app.model.Wrap { pair: p };
|
||||
let state = app.model.State::Done(w.pair);
|
||||
match state { app.model.State::Done(pair) => { return app.model.total(pair); } app.model.State::Empty => { return 0; } }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// expect: run
|
||||
// result: 42
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
module app.entry
|
||||
struct Pair { value: u64 }
|
||||
fn total(pair: Pair) -> u64 effects [] { return pair.value; }
|
||||
fn main() -> u64 effects [] { return app.entry.total(app.entry.Pair { value: 42 }); }
|
||||
@@ -0,0 +1,6 @@
|
||||
// expect: reject E7006
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
module app.entry
|
||||
import app.entry;
|
||||
fn main() -> u64 effects [] { return 42; }
|
||||
@@ -0,0 +1,7 @@
|
||||
// expect: reject E7001
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// module: app.broken=source/modules/bad_syntax.aji.inc
|
||||
module app.entry
|
||||
import app.broken;
|
||||
fn main() -> u64 effects [] { return 42; }
|
||||
@@ -0,0 +1,9 @@
|
||||
// expect: run
|
||||
// result: 10
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// schedules: 8
|
||||
// module: app.model=source/modules/model.aji.inc
|
||||
module app.entry
|
||||
import app.model;
|
||||
fn main() -> u64 effects [task.spawn, task.wait] { var result: u64 = 0; scope s { let t = task.spawn(s, app.model.local); result = task.join(move t); } return result; }
|
||||
@@ -0,0 +1,31 @@
|
||||
// Two tasks square the two halves of one buffer; the halves are lent until the joins.
|
||||
// expect: run
|
||||
// result: [1,4,9,16]
|
||||
// equivalent: phase3/run/tasks_parallel_square.air
|
||||
// schedules: 8
|
||||
// module: app.workers=source/modules/workers.aji.inc
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md
|
||||
module app.entry
|
||||
import app.workers;
|
||||
|
||||
fn main() -> [u64; 4]
|
||||
effects [task.spawn]
|
||||
{
|
||||
var buf: [u64; 4] = zero;
|
||||
buf[0] = 1;
|
||||
buf[1] = 2;
|
||||
buf[2] = 3;
|
||||
buf[3] = 4;
|
||||
{
|
||||
mut s = buf;
|
||||
let (l, r) = s.split_at(2);
|
||||
scope sc {
|
||||
let t1 = task.spawn(sc, app.workers.square, l);
|
||||
let t2 = task.spawn(sc, app.workers.square, r);
|
||||
task.join(move t1);
|
||||
task.join(move t2);
|
||||
}
|
||||
}
|
||||
buf
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// The same exclusive borrow lent to two live tasks: a possible data race (E4101).
|
||||
// expect: reject E4101
|
||||
// module: app.workers=source/modules/workers.aji.inc
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md
|
||||
module app.entry
|
||||
import app.workers;
|
||||
|
||||
fn main() -> u64
|
||||
effects [task.spawn]
|
||||
{
|
||||
var buf: [u64; 2] = zero;
|
||||
{
|
||||
mut s = buf;
|
||||
scope sc {
|
||||
let a = task.spawn(sc, app.workers.bump, s);
|
||||
let b = task.spawn(sc, app.workers.bump, s);
|
||||
task.join(move a);
|
||||
task.join(move b);
|
||||
}
|
||||
}
|
||||
buf[0]
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// expect: reject E7002
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// module: app.model=source/modules/model.aji.inc
|
||||
// module: app.work=source/modules/work.aji.inc
|
||||
module app.entry
|
||||
import app.work;
|
||||
fn main() -> u64 effects [task.spawn, task.wait] {
|
||||
scope s {
|
||||
let t = task.spawn(s, app.model.local);
|
||||
return task.join(move t);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// expect: reject E7002
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// module: app.work=source/modules/work.aji.inc
|
||||
// module: app.model=source/modules/model.aji.inc
|
||||
module app.entry
|
||||
import app.work;
|
||||
fn main() -> u64 effects [] { return app.model.local(); }
|
||||
@@ -0,0 +1,8 @@
|
||||
// expect: reject E7002
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// module: app.work=source/modules/work.aji.inc
|
||||
// module: app.model=source/modules/model.aji.inc
|
||||
module app.entry
|
||||
import app.work;
|
||||
fn main() -> u64 effects [] { let value = app.model.State::Empty; return 42; }
|
||||
@@ -0,0 +1,8 @@
|
||||
// expect: reject E7002
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// module: app.work=source/modules/work.aji.inc
|
||||
// module: app.model=source/modules/model.aji.inc
|
||||
module app.entry
|
||||
import app.work;
|
||||
fn main() -> u64 effects [] { let pair: app.model.Pair = app.work.run(); return pair.left; }
|
||||
@@ -0,0 +1,7 @@
|
||||
// expect: reject E7002
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// module: app.model=source/modules/model.aji.inc
|
||||
module app.entry
|
||||
import app.model;
|
||||
fn main() -> u64 effects [] { return app.model.nope(); }
|
||||
@@ -0,0 +1,7 @@
|
||||
// expect: run
|
||||
// result: 42
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §14
|
||||
// module: app.broken=source/modules/bad_syntax.aji.inc
|
||||
module app.entry
|
||||
fn main() -> u64 effects [] { return 42; }
|
||||
@@ -0,0 +1,5 @@
|
||||
module app.work
|
||||
import app.model;
|
||||
import std.math;
|
||||
fn run() -> app.model.Pair effects [] { return app.model.make(); }
|
||||
fn bounded(value: u64) -> u64 effects [] { return std.math.min_u64(value, 42); }
|
||||
@@ -0,0 +1,3 @@
|
||||
module app.workers
|
||||
fn square(s: slice_mut<u64>) -> void effects [] { for i in 0..s.len { s[i] = s[i] * s[i]; } }
|
||||
fn bump(s: slice_mut<u64>) -> void effects [] { s[0] = s[0] + 1; }
|
||||
Reference in new issue
Block a user