verifier: cache structural properties and nominal size queries

This commit is contained in:
dev committed 2026-10-08 13:33:24 +03:00
1 parent 41f3afbf05
commit 48b9b42fed
31 files changed
+1399 -166

No files matched your search

@@ -0,0 +1,52 @@
; expect: reject E1003
; phase: 6
; spec: docs/spec/03-memory-model.md §25
module test.nominal_queries
air 0
lang 0.1
features []
type @N0 = struct { a: @N1, b: @N1 }
type @N1 = struct { a: @N2, b: @N2 }
type @N2 = struct { a: @N3, b: @N3 }
type @N3 = struct { a: @N4, b: @N4 }
type @N4 = struct { a: @N5, b: @N5 }
type @N5 = struct { a: @N6, b: @N6 }
type @N6 = struct { a: @N7, b: @N7 }
type @N7 = struct { a: @N8, b: @N8 }
type @N8 = struct { a: @N9, b: @N9 }
type @N9 = struct { a: @N10, b: @N10 }
type @N10 = struct { a: @N11, b: @N11 }
type @N11 = struct { a: @N12, b: @N12 }
type @N12 = struct { a: @N13, b: @N13 }
type @N13 = struct { a: @N14, b: @N14 }
type @N14 = struct { a: @N15, b: @N15 }
type @N15 = struct { a: @N16, b: @N16 }
type @N16 = struct { a: @N17, b: @N17 }
type @N17 = struct { a: @N18, b: @N18 }
type @N18 = struct { a: @N19, b: @N19 }
type @N19 = struct { a: @N20, b: @N20 }
type @N20 = struct { a: @N21, b: @N21 }
type @N21 = struct { a: @N22, b: @N22 }
type @N22 = struct { a: @N23, b: @N23 }
type @N23 = struct { a: @N24, b: @N24 }
type @N24 = struct { a: @N25, b: @N25 }
type @N25 = struct { a: @N26, b: @N26 }
type @N26 = struct { a: @N27, b: @N27 }
type @N27 = struct { a: @N28, b: @N28 }
type @N28 = struct { a: @N29, b: @N29 }
type @N29 = struct { a: @N30, b: @N30 }
type @N30 = struct { a: @N31, b: @N31 }
type @N31 = struct { a: @N32, b: @N32 }
type @N32 = struct { a: @N33, b: @N33 }
type @N33 = struct { a: @N34, b: @N34 }
type @N34 = struct { a: @N35, b: @N35 }
type @N35 = struct { a: @N36, b: @N36 }
type @N36 = struct { a: @N37, b: @N37 }
type @N37 = struct { a: @N38, b: @N38 }
type @N38 = struct { a: @N39, b: @N39 }
type @N39 = struct { a: @N40, b: @N40 }
type @N40 = struct { a: @N0, b: @N0 }
fn @main() -> void
effects []
entry:
ret
@@ -0,0 +1,34 @@
; expect: run
; result: 42
; phase: 6
; spec: docs/spec/08-verifier.md §7
module test.nominal_queries
air 0
lang 0.1
features []
type @N0 = struct { a: @N1, b: @N1 }
type @N1 = struct { a: @N2, b: @N2 }
type @N2 = struct { a: @N3, b: @N3 }
type @N3 = struct { a: @N4, b: @N4 }
type @N4 = struct { a: @N5, b: @N5 }
type @N5 = struct { a: @N6, b: @N6 }
type @N6 = struct { a: @N7, b: @N7 }
type @N7 = struct { a: @N8, b: @N8 }
type @N8 = struct { a: @N9, b: @N9 }
type @N9 = struct { a: @N10, b: @N10 }
type @N10 = struct { a: @N11, b: @N11 }
type @N11 = struct { a: @N12, b: @N12 }
type @N12 = struct { a: @N13, b: @N13 }
type @N13 = struct { a: @N14, b: @N14 }
type @N14 = struct { a: @N15, b: @N15 }
type @N15 = struct { a: @N16, b: @N16 }
type @N16 = struct { x: u64 }
fn @echo(%p: @N0) -> @N0
effects []
entry:
ret %p
fn @main() -> u64
effects []
entry:
%answer = const.u64 42
ret %answer
@@ -0,0 +1,38 @@
; expect: reject E5101 E5101 E5101 E5101
; phase: 6
; spec: docs/spec/08-verifier.md §7
module test.nominal_queries
air 0
lang 0.1
features []
type @N0 = struct { a: @N1, b: @N1 }
type @N1 = struct { a: @N2, b: @N2 }
type @N2 = struct { a: @N3, b: @N3 }
type @N3 = struct { a: @N4, b: @N4 }
type @N4 = struct { a: @N5, b: @N5 }
type @N5 = struct { a: @N6, b: @N6 }
type @N6 = struct { a: @N7, b: @N7 }
type @N7 = struct { a: @N8, b: @N8 }
type @N8 = struct { a: @N9, b: @N9 }
type @N9 = struct { a: @N10, b: @N10 }
type @N10 = struct { a: @N11, b: @N11 }
type @N11 = struct { a: @N12, b: @N12 }
type @N12 = struct { a: @N13, b: @N13 }
type @N13 = struct { a: @N14, b: @N14 }
type @N14 = struct { a: @N15, b: @N15 }
type @N15 = struct { a: @N16, b: @N16 }
type @N16 = struct { a: @N17, b: @N17 }
type @N17 = struct { a: @N18, b: @N18 }
type @N18 = struct { a: @N19, b: @N19 }
type @N19 = struct { a: @N20, b: @N20 }
type @N20 = struct { a: @N21, b: @N21 }
type @N21 = struct { x: u64 }
fn @echo(%p: @N0) -> @N0
effects []
entry:
ret %p
fn @main() -> u64
effects []
entry:
%answer = const.u64 42
ret %answer
@@ -0,0 +1,82 @@
; expect: run
; result: 42
; phase: 6
; spec: docs/spec/08-verifier.md §7
module test.nominal_queries
air 0
lang 0.1
features []
type @N0 = struct { a: @N1, b: @N1 }
type @N1 = struct { a: @N2, b: @N2 }
type @N2 = struct { a: @N3, b: @N3 }
type @N3 = struct { a: @N4, b: @N4 }
type @N4 = struct { a: @N5, b: @N5 }
type @N5 = struct { a: @N6, b: @N6 }
type @N6 = struct { a: @N7, b: @N7 }
type @N7 = struct { a: @N8, b: @N8 }
type @N8 = struct { a: @N9, b: @N9 }
type @N9 = struct { a: @N10, b: @N10 }
type @N10 = struct { a: @N11, b: @N11 }
type @N11 = struct { a: @N12, b: @N12 }
type @N12 = struct { a: @N13, b: @N13 }
type @N13 = struct { a: @N14, b: @N14 }
type @N14 = struct { a: @N15, b: @N15 }
type @N15 = struct { a: @N16, b: @N16 }
type @N16 = struct { a: @N17, b: @N17 }
type @N17 = struct { a: @N18, b: @N18 }
type @N18 = struct { a: @N19, b: @N19 }
type @N19 = struct { a: @N20, b: @N20 }
type @N20 = struct { a: @N21, b: @N21 }
type @N21 = struct { a: @N22, b: @N22 }
type @N22 = struct { a: @N23, b: @N23 }
type @N23 = struct { a: @N24, b: @N24 }
type @N24 = struct { a: @N25, b: @N25 }
type @N25 = struct { a: @N26, b: @N26 }
type @N26 = struct { a: @N27, b: @N27 }
type @N27 = struct { a: @N28, b: @N28 }
type @N28 = struct { a: @N29, b: @N29 }
type @N29 = struct { a: @N30, b: @N30 }
type @N30 = struct { a: @N31, b: @N31 }
type @N31 = struct { a: @N32, b: @N32 }
type @N32 = struct { a: @N33, b: @N33 }
type @N33 = struct { a: @N34, b: @N34 }
type @N34 = struct { a: @N35, b: @N35 }
type @N35 = struct { a: @N36, b: @N36 }
type @N36 = struct { a: @N37, b: @N37 }
type @N37 = struct { a: @N38, b: @N38 }
type @N38 = struct { a: @N39, b: @N39 }
type @N39 = struct { a: @N40, b: @N40 }
type @N40 = struct { a: @N41, b: @N41 }
type @N41 = struct { a: @N42, b: @N42 }
type @N42 = struct { a: @N43, b: @N43 }
type @N43 = struct { a: @N44, b: @N44 }
type @N44 = struct { a: @N45, b: @N45 }
type @N45 = struct { a: @N46, b: @N46 }
type @N46 = struct { a: @N47, b: @N47 }
type @N47 = struct { a: @N48, b: @N48 }
type @N48 = struct { a: @N49, b: @N49 }
type @N49 = struct { a: @N50, b: @N50 }
type @N50 = struct { a: @N51, b: @N51 }
type @N51 = struct { a: @N52, b: @N52 }
type @N52 = struct { a: @N53, b: @N53 }
type @N53 = struct { a: @N54, b: @N54 }
type @N54 = struct { a: @N55, b: @N55 }
type @N55 = struct { a: @N56, b: @N56 }
type @N56 = struct { a: @N57, b: @N57 }
type @N57 = struct { a: @N58, b: @N58 }
type @N58 = struct { a: @N59, b: @N59 }
type @N59 = struct { a: @N60, b: @N60 }
type @N60 = struct { a: @N61, b: @N61 }
type @N61 = struct { a: @N62, b: @N62 }
type @N62 = struct { a: @N63, b: @N63 }
type @N63 = struct { a: @N64, b: @N64 }
type @N64 = struct {}
fn @echo(%p: @N0) -> @N0
effects []
entry:
ret %p
fn @main() -> u64
effects []
entry:
%answer = const.u64 42
ret %answer
@@ -0,0 +1,14 @@
; expect: run
; result: 42
; phase: 6
; spec: docs/spec/03-memory-model.md §22
module test.nominal_queries
air 0
lang 0.1
features [capabilities, effects, heap, islands, ownership, resources]
type @N0 = struct { next: iref<@N0> }
fn @main() -> u64
effects []
entry:
%n = const.u64 42
ret %n
@@ -0,0 +1,47 @@
// expect: reject E7005
// phase: 6
// spec: docs/spec/15-source-language.md §5/§15
module test.nominal_queries
struct N0 { a: N1 }
struct N1 { a: N2 }
struct N2 { a: N3 }
struct N3 { a: N4 }
struct N4 { a: N5 }
struct N5 { a: N6 }
struct N6 { a: N7 }
struct N7 { a: N8 }
struct N8 { a: N9 }
struct N9 { a: N10 }
struct N10 { a: N11 }
struct N11 { a: N12 }
struct N12 { a: N13 }
struct N13 { a: N14 }
struct N14 { a: N15 }
struct N15 { a: N16 }
struct N16 { a: N17 }
struct N17 { a: N18 }
struct N18 { a: N19 }
struct N19 { a: N20 }
struct N20 { a: N21 }
struct N21 { a: N22 }
struct N22 { a: N23 }
struct N23 { a: N24 }
struct N24 { a: N25 }
struct N25 { a: N26 }
struct N26 { a: N27 }
struct N27 { a: N28 }
struct N28 { a: N29 }
struct N29 { a: N30 }
struct N30 { a: N31 }
struct N31 { a: N32 }
struct N32 { a: N33 }
struct N33 { a: N34 }
struct N34 { a: N35 }
struct N35 { a: N36 }
struct N36 { a: N37 }
struct N37 { a: N38 }
struct N38 { a: N39 }
struct N39 { a: N40 }
struct N40 { x: ref<u64> }
fn echo(p: N0) -> N0 effects [] { return move p; }
fn main() -> u64 effects [] { return 42; }
@@ -0,0 +1,71 @@
// expect: reject E7006
// phase: 6
// spec: docs/spec/15-source-language.md §5/§15
module test.nominal_queries
struct N0 { a: N1 }
struct N1 { a: N2 }
struct N2 { a: N3 }
struct N3 { a: N4 }
struct N4 { a: N5 }
struct N5 { a: N6 }
struct N6 { a: N7 }
struct N7 { a: N8 }
struct N8 { a: N9 }
struct N9 { a: N10 }
struct N10 { a: N11 }
struct N11 { a: N12 }
struct N12 { a: N13 }
struct N13 { a: N14 }
struct N14 { a: N15 }
struct N15 { a: N16 }
struct N16 { a: N17 }
struct N17 { a: N18 }
struct N18 { a: N19 }
struct N19 { a: N20 }
struct N20 { a: N21 }
struct N21 { a: N22 }
struct N22 { a: N23 }
struct N23 { a: N24 }
struct N24 { a: N25 }
struct N25 { a: N26 }
struct N26 { a: N27 }
struct N27 { a: N28 }
struct N28 { a: N29 }
struct N29 { a: N30 }
struct N30 { a: N31 }
struct N31 { a: N32 }
struct N32 { a: N33 }
struct N33 { a: N34 }
struct N34 { a: N35 }
struct N35 { a: N36 }
struct N36 { a: N37 }
struct N37 { a: N38 }
struct N38 { a: N39 }
struct N39 { a: N40 }
struct N40 { a: N41 }
struct N41 { a: N42 }
struct N42 { a: N43 }
struct N43 { a: N44 }
struct N44 { a: N45 }
struct N45 { a: N46 }
struct N46 { a: N47 }
struct N47 { a: N48 }
struct N48 { a: N49 }
struct N49 { a: N50 }
struct N50 { a: N51 }
struct N51 { a: N52 }
struct N52 { a: N53 }
struct N53 { a: N54 }
struct N54 { a: N55 }
struct N55 { a: N56 }
struct N56 { a: N57 }
struct N57 { a: N58 }
struct N58 { a: N59 }
struct N59 { a: N60 }
struct N60 { a: N61 }
struct N61 { a: N62 }
struct N62 { a: N63 }
struct N63 { a: N64 }
struct N64 { x: u64 }
fn marker<T: Copy>() -> u64 effects [] { return 42; }
fn main() -> u64 effects [] { return marker::<N0>(); }
@@ -0,0 +1,46 @@
// expect: reject E1003
// phase: 6
// spec: docs/spec/03-memory-model.md §22/§25
module test.nominal_queries
struct N0 { a: N1, b: N1 }
struct N1 { a: N2, b: N2 }
struct N2 { a: N3, b: N3 }
struct N3 { a: N4, b: N4 }
struct N4 { a: N5, b: N5 }
struct N5 { a: N6, b: N6 }
struct N6 { a: N7, b: N7 }
struct N7 { a: N8, b: N8 }
struct N8 { a: N9, b: N9 }
struct N9 { a: N10, b: N10 }
struct N10 { a: N11, b: N11 }
struct N11 { a: N12, b: N12 }
struct N12 { a: N13, b: N13 }
struct N13 { a: N14, b: N14 }
struct N14 { a: N15, b: N15 }
struct N15 { a: N16, b: N16 }
struct N16 { a: N17, b: N17 }
struct N17 { a: N18, b: N18 }
struct N18 { a: N19, b: N19 }
struct N19 { a: N20, b: N20 }
struct N20 { a: N21, b: N21 }
struct N21 { a: N22, b: N22 }
struct N22 { a: N23, b: N23 }
struct N23 { a: N24, b: N24 }
struct N24 { a: N25, b: N25 }
struct N25 { a: N26, b: N26 }
struct N26 { a: N27, b: N27 }
struct N27 { a: N28, b: N28 }
struct N28 { a: N29, b: N29 }
struct N29 { a: N30, b: N30 }
struct N30 { a: N31, b: N31 }
struct N31 { a: N32, b: N32 }
struct N32 { a: N33, b: N33 }
struct N33 { a: N34, b: N34 }
struct N34 { a: N35, b: N35 }
struct N35 { a: N36, b: N36 }
struct N36 { a: N37, b: N37 }
struct N37 { a: N38, b: N38 }
struct N38 { a: N39, b: N39 }
struct N39 { a: N40, b: N40 }
struct N40 { a: N0, b: N0 }
fn main() -> u64 effects [] { return 42; }
@@ -0,0 +1,24 @@
// expect: run
// result: 42
// phase: 6
// spec: docs/spec/08-verifier.md §7; docs/spec/15-source-language.md §10
module test.nominal_queries
struct N0 { a: N1, b: N1 }
struct N1 { a: N2, b: N2 }
struct N2 { a: N3, b: N3 }
struct N3 { a: N4, b: N4 }
struct N4 { a: N5, b: N5 }
struct N5 { a: N6, b: N6 }
struct N6 { a: N7, b: N7 }
struct N7 { a: N8, b: N8 }
struct N8 { a: N9, b: N9 }
struct N9 { a: N10, b: N10 }
struct N10 { a: N11, b: N11 }
struct N11 { a: N12, b: N12 }
struct N12 { a: N13, b: N13 }
struct N13 { a: N14, b: N14 }
struct N14 { a: N15, b: N15 }
struct N15 { a: N16, b: N16 }
struct N16 { x: u64 }
fn echo(p: N0) -> N0 effects [] { return p; }
fn main() -> u64 effects [] { return 42; }
@@ -0,0 +1,28 @@
// expect: reject E5101 E5101 E5101 E5101
// phase: 6
// spec: docs/spec/08-verifier.md §7; docs/spec/15-source-language.md §10
module test.nominal_queries
struct N0 { a: N1, b: N1 }
struct N1 { a: N2, b: N2 }
struct N2 { a: N3, b: N3 }
struct N3 { a: N4, b: N4 }
struct N4 { a: N5, b: N5 }
struct N5 { a: N6, b: N6 }
struct N6 { a: N7, b: N7 }
struct N7 { a: N8, b: N8 }
struct N8 { a: N9, b: N9 }
struct N9 { a: N10, b: N10 }
struct N10 { a: N11, b: N11 }
struct N11 { a: N12, b: N12 }
struct N12 { a: N13, b: N13 }
struct N13 { a: N14, b: N14 }
struct N14 { a: N15, b: N15 }
struct N15 { a: N16, b: N16 }
struct N16 { a: N17, b: N17 }
struct N17 { a: N18, b: N18 }
struct N18 { a: N19, b: N19 }
struct N19 { a: N20, b: N20 }
struct N20 { a: N21, b: N21 }
struct N21 { x: u64 }
fn echo(p: N0) -> N0 effects [] { return p; }
fn main() -> u64 effects [] { return 42; }
@@ -0,0 +1,72 @@
// expect: run
// result: 42
// phase: 6
// spec: docs/spec/08-verifier.md §7; docs/spec/15-source-language.md §10
module test.nominal_queries
struct N0 { a: N1, b: N1 }
struct N1 { a: N2, b: N2 }
struct N2 { a: N3, b: N3 }
struct N3 { a: N4, b: N4 }
struct N4 { a: N5, b: N5 }
struct N5 { a: N6, b: N6 }
struct N6 { a: N7, b: N7 }
struct N7 { a: N8, b: N8 }
struct N8 { a: N9, b: N9 }
struct N9 { a: N10, b: N10 }
struct N10 { a: N11, b: N11 }
struct N11 { a: N12, b: N12 }
struct N12 { a: N13, b: N13 }
struct N13 { a: N14, b: N14 }
struct N14 { a: N15, b: N15 }
struct N15 { a: N16, b: N16 }
struct N16 { a: N17, b: N17 }
struct N17 { a: N18, b: N18 }
struct N18 { a: N19, b: N19 }
struct N19 { a: N20, b: N20 }
struct N20 { a: N21, b: N21 }
struct N21 { a: N22, b: N22 }
struct N22 { a: N23, b: N23 }
struct N23 { a: N24, b: N24 }
struct N24 { a: N25, b: N25 }
struct N25 { a: N26, b: N26 }
struct N26 { a: N27, b: N27 }
struct N27 { a: N28, b: N28 }
struct N28 { a: N29, b: N29 }
struct N29 { a: N30, b: N30 }
struct N30 { a: N31, b: N31 }
struct N31 { a: N32, b: N32 }
struct N32 { a: N33, b: N33 }
struct N33 { a: N34, b: N34 }
struct N34 { a: N35, b: N35 }
struct N35 { a: N36, b: N36 }
struct N36 { a: N37, b: N37 }
struct N37 { a: N38, b: N38 }
struct N38 { a: N39, b: N39 }
struct N39 { a: N40, b: N40 }
struct N40 { a: N41, b: N41 }
struct N41 { a: N42, b: N42 }
struct N42 { a: N43, b: N43 }
struct N43 { a: N44, b: N44 }
struct N44 { a: N45, b: N45 }
struct N45 { a: N46, b: N46 }
struct N46 { a: N47, b: N47 }
struct N47 { a: N48, b: N48 }
struct N48 { a: N49, b: N49 }
struct N49 { a: N50, b: N50 }
struct N50 { a: N51, b: N51 }
struct N51 { a: N52, b: N52 }
struct N52 { a: N53, b: N53 }
struct N53 { a: N54, b: N54 }
struct N54 { a: N55, b: N55 }
struct N55 { a: N56, b: N56 }
struct N56 { a: N57, b: N57 }
struct N57 { a: N58, b: N58 }
struct N58 { a: N59, b: N59 }
struct N59 { a: N60, b: N60 }
struct N60 { a: N61, b: N61 }
struct N61 { a: N62, b: N62 }
struct N62 { a: N63, b: N63 }
struct N63 { a: N64, b: N64 }
struct N64 {}
fn echo(p: N0) -> N0 effects [] { return p; }
fn main() -> u64 effects [] { return 42; }
@@ -0,0 +1,48 @@
// expect: run
// result: 42
// phase: 6
// spec: docs/spec/15-source-language.md §15
module test.nominal_queries
struct N0 { a: N1 }
struct N1 { a: N2 }
struct N2 { a: N3 }
struct N3 { a: N4 }
struct N4 { a: N5 }
struct N5 { a: N6 }
struct N6 { a: N7 }
struct N7 { a: N8 }
struct N8 { a: N9 }
struct N9 { a: N10 }
struct N10 { a: N11 }
struct N11 { a: N12 }
struct N12 { a: N13 }
struct N13 { a: N14 }
struct N14 { a: N15 }
struct N15 { a: N16 }
struct N16 { a: N17 }
struct N17 { a: N18 }
struct N18 { a: N19 }
struct N19 { a: N20 }
struct N20 { a: N21 }
struct N21 { a: N22 }
struct N22 { a: N23 }
struct N23 { a: N24 }
struct N24 { a: N25 }
struct N25 { a: N26 }
struct N26 { a: N27 }
struct N27 { a: N28 }
struct N28 { a: N29 }
struct N29 { a: N30 }
struct N30 { a: N31 }
struct N31 { a: N32 }
struct N32 { a: N33 }
struct N33 { a: N34 }
struct N34 { a: N35 }
struct N35 { a: N36 }
struct N36 { a: N37 }
struct N37 { a: N38 }
struct N38 { a: N39 }
struct N39 { a: N40 }
struct N40 { x: u64 }
fn marker<T: Copy>() -> u64 effects [] { return 42; }
fn main() -> u64 effects [] { return marker::<N0>(); }
@@ -0,0 +1,48 @@
// expect: run
// result: 42
// phase: 6
// spec: docs/spec/15-source-language.md §15
module test.nominal_queries
struct N0 { a: N1 }
struct N1 { a: N2 }
struct N2 { a: N3 }
struct N3 { a: N4 }
struct N4 { a: N5 }
struct N5 { a: N6 }
struct N6 { a: N7 }
struct N7 { a: N8 }
struct N8 { a: N9 }
struct N9 { a: N10 }
struct N10 { a: N11 }
struct N11 { a: N12 }
struct N12 { a: N13 }
struct N13 { a: N14 }
struct N14 { a: N15 }
struct N15 { a: N16 }
struct N16 { a: N17 }
struct N17 { a: N18 }
struct N18 { a: N19 }
struct N19 { a: N20 }
struct N20 { a: N21 }
struct N21 { a: N22 }
struct N22 { a: N23 }
struct N23 { a: N24 }
struct N24 { a: N25 }
struct N25 { a: N26 }
struct N26 { a: N27 }
struct N27 { a: N28 }
struct N28 { a: N29 }
struct N29 { a: N30 }
struct N30 { a: N31 }
struct N31 { a: N32 }
struct N32 { a: N33 }
struct N33 { a: N34 }
struct N34 { a: N35 }
struct N35 { a: N36 }
struct N36 { a: N37 }
struct N37 { a: N38 }
struct N38 { a: N39 }
struct N39 { a: N40 }
struct N40 { x: u64 }
fn marker<T: Freeze>() -> u64 effects [] { return 42; }
fn main() -> u64 effects [] { return marker::<N0>(); }
@@ -0,0 +1,48 @@
// expect: run
// result: 42
// phase: 6
// spec: docs/spec/15-source-language.md §15
module test.nominal_queries
struct N0 { a: N1 }
struct N1 { a: N2 }
struct N2 { a: N3 }
struct N3 { a: N4 }
struct N4 { a: N5 }
struct N5 { a: N6 }
struct N6 { a: N7 }
struct N7 { a: N8 }
struct N8 { a: N9 }
struct N9 { a: N10 }
struct N10 { a: N11 }
struct N11 { a: N12 }
struct N12 { a: N13 }
struct N13 { a: N14 }
struct N14 { a: N15 }
struct N15 { a: N16 }
struct N16 { a: N17 }
struct N17 { a: N18 }
struct N18 { a: N19 }
struct N19 { a: N20 }
struct N20 { a: N21 }
struct N21 { a: N22 }
struct N22 { a: N23 }
struct N23 { a: N24 }
struct N24 { a: N25 }
struct N25 { a: N26 }
struct N26 { a: N27 }
struct N27 { a: N28 }
struct N28 { a: N29 }
struct N29 { a: N30 }
struct N30 { a: N31 }
struct N31 { a: N32 }
struct N32 { a: N33 }
struct N33 { a: N34 }
struct N34 { a: N35 }
struct N35 { a: N36 }
struct N36 { a: N37 }
struct N37 { a: N38 }
struct N38 { a: N39 }
struct N39 { a: N40 }
struct N40 { x: u64 }
fn marker<T: Send>() -> u64 effects [] { return 42; }
fn main() -> u64 effects [] { return marker::<N0>(); }
@@ -0,0 +1,48 @@
// expect: run
// result: 42
// phase: 6
// spec: docs/spec/15-source-language.md §15
module test.nominal_queries
struct N0 { a: N1 }
struct N1 { a: N2 }
struct N2 { a: N3 }
struct N3 { a: N4 }
struct N4 { a: N5 }
struct N5 { a: N6 }
struct N6 { a: N7 }
struct N7 { a: N8 }
struct N8 { a: N9 }
struct N9 { a: N10 }
struct N10 { a: N11 }
struct N11 { a: N12 }
struct N12 { a: N13 }
struct N13 { a: N14 }
struct N14 { a: N15 }
struct N15 { a: N16 }
struct N16 { a: N17 }
struct N17 { a: N18 }
struct N18 { a: N19 }
struct N19 { a: N20 }
struct N20 { a: N21 }
struct N21 { a: N22 }
struct N22 { a: N23 }
struct N23 { a: N24 }
struct N24 { a: N25 }
struct N25 { a: N26 }
struct N26 { a: N27 }
struct N27 { a: N28 }
struct N28 { a: N29 }
struct N29 { a: N30 }
struct N30 { a: N31 }
struct N31 { a: N32 }
struct N32 { a: N33 }
struct N33 { a: N34 }
struct N34 { a: N35 }
struct N35 { a: N36 }
struct N36 { a: N37 }
struct N37 { a: N38 }
struct N38 { a: N39 }
struct N39 { a: N40 }
struct N40 { x: u64 }
fn marker<T: Share>() -> u64 effects [] { return 42; }
fn main() -> u64 effects [] { return marker::<N0>(); }
@@ -0,0 +1,48 @@
// expect: run
// result: 42
// phase: 6
// spec: docs/spec/15-source-language.md §5/§15
module test.nominal_queries
struct N0 { a: N1 }
struct N1 { a: N2 }
struct N2 { a: N3 }
struct N3 { a: N4 }
struct N4 { a: N5 }
struct N5 { a: N6 }
struct N6 { a: N7 }
struct N7 { a: N8 }
struct N8 { a: N9 }
struct N9 { a: N10 }
struct N10 { a: N11 }
struct N11 { a: N12 }
struct N12 { a: N13 }
struct N13 { a: N14 }
struct N14 { a: N15 }
struct N15 { a: N16 }
struct N16 { a: N17 }
struct N17 { a: N18 }
struct N18 { a: N19 }
struct N19 { a: N20 }
struct N20 { a: N21 }
struct N21 { a: N22 }
struct N22 { a: N23 }
struct N23 { a: N24 }
struct N24 { a: N25 }
struct N25 { a: N26 }
struct N26 { a: N27 }
struct N27 { a: N28 }
struct N28 { a: N29 }
struct N29 { a: N30 }
struct N30 { a: N31 }
struct N31 { a: N32 }
struct N32 { a: N33 }
struct N33 { a: N34 }
struct N34 { a: N35 }
struct N35 { a: N36 }
struct N36 { a: N37 }
struct N37 { a: N38 }
struct N38 { a: N39 }
struct N39 { a: N40 }
struct N40 { x: own<u64> }
fn echo(p: N0) -> N0 effects [] { return move p; }
fn main() -> u64 effects [] { return 42; }
@@ -0,0 +1,7 @@
// expect: run
// result: 42
// phase: 6
// spec: docs/spec/03-memory-model.md §22/§25
module test.nominal_queries
struct N0 { next: iref<N0> }
fn main() -> u64 effects [] { return 42; }
+88
View File
@@ -0,0 +1,88 @@
#!/usr/bin/env python3
"""Deep shared types: CLI/format/profile parity and imported cache indices."""
import json
from pathlib import Path
import subprocess
import tempfile
REPO = Path(__file__).resolve().parents[2]
AJI = REPO / 'zig-out/bin/aji'
CORPUS = REPO / 'tests/conformance/source/nominal_queries'
checks = 0
def cli(*args, code=0):
global checks
result = subprocess.run([str(AJI), *map(str, args)], capture_output=True, text=True)
assert result.returncode == code, (args, result.returncode, result.stdout, result.stderr)
checks += 1
return result.stdout
with tempfile.TemporaryDirectory(prefix='aji-nominal-queries-') as directory:
root = Path(directory)
for source in sorted(CORPUS.glob('*.aji')):
formatted = root / source.name
formatted.write_text(cli('fmt', source))
cli('fmt', '--check', formatted)
assert cli('fmt', formatted) == formatted.read_text()
if '// expect: reject' in source.read_text():
diagnostics = cli('check', source, code=1)
for command in ('run', 'report', 'explore'):
assert cli(command, source, code=1) == diagnostics
records = [json.loads(line) for line in diagnostics.splitlines()]
assert all(d['file'] == str(source) for d in records), records
if source.stem == 'cycle':
assert (records[0]['code'], records[0]['type'], records[0]['line']) == ('E1003', 'N0', 5)
elif source.stem == 'constraint_depth':
assert records[0]['reason'] == 'implementation_limit'
elif source.stem == 'diamond_21_u64':
assert [d['found'] for d in records] == [16777216, 8388608, 4194304, 2097152]
# Lowering emits AIR; the subsequent budget stage rejects it.
raw = root / 'oversized.air'
raw.write_text(cli('lower', source))
raw_records = [json.loads(line) for line in cli('check', raw, code=1).splitlines()]
assert [(d['code'], d['found']) for d in raw_records] == [(d['code'], d['found']) for d in records]
if source.stem != 'diamond_21_u64':
assert cli('lower', source, code=1) == diagnostics
continue
air = cli('lower', source)
assert cli('lower', formatted) == air
raw = root / f'{source.stem}.air'
raw.write_text(air)
cli('check', raw)
expected = json.loads(cli('run', '--fuel', '100000', source))
assert expected['value'] == 42, expected
assert json.loads(cli('run', '--fuel', '100000', raw)) == expected
result = root / f'{source.stem}.json'
cli('run', '--profile', 'hosted', '--fuel', '100000', '--result-file', result, source)
assert json.loads(result.read_text())['value'] == 42
library, entry, manifest = (root / name for name in ('nodes.aji', 'main.aji', 'aji.toml'))
library.write_text('module lib.nodes\n' + '\n'.join(
f'struct N{i} {{ a: N{i + 1} }}' for i in range(40)) + '\nstruct N40 { x: u64 }\n')
entry.write_text('module app\nimport lib.nodes;\n'
'fn marker<T: Copy + Send + Share + Freeze>() -> u64 effects [] { return 42; }\n'
'fn main() -> u64 effects [] { return marker::<lib.nodes.N0>(); }\n')
manifest.write_text('[package]\nname = "nodes"\nversion = "1"\nentry = "main.aji"\n'
'[modules]\nlib.nodes = "nodes.aji"\n')
assert json.loads(cli('run', '--manifest', manifest))['value'] == 42
# Actual allocation accounting reads a verified nominal cache at runtime.
allocated = root / 'allocated.aji'
declarations = library.read_text().replace('module lib.nodes', 'module app')
bindings = 'let n40 = N40 { x: 42u64 };\n' + '\n'.join(
f'let n{i} = N{i} {{ a: n{i + 1} }};' for i in reversed(range(40)))
allocated.write_text(declarations + '\nfn main(heap: cap<mem.alloc>) -> u64 effects [mem.alloc] {\n' +
bindings + '\nlet p = own.new(n0, heap) or trap; let n = own.take(move p);\nreturn n' + '.a' * 40 + '.x; }\n')
raw = root / 'allocated.air'
raw.write_text(cli('lower', allocated))
grants = ['--grant', 'heap=mem.alloc:8']
result = json.loads(cli('run', '--fuel', '100000', *grants, allocated))
assert result['value'] == 42, result
assert json.loads(cli('run', '--fuel', '100000', *grants, raw)) == result
library.write_text(library.read_text().replace('struct N40 { x: u64 }', 'struct N40 { x: N0 }'))
record = json.loads(cli('check', '--manifest', manifest, code=1))
assert (record['code'], record['file'], record['line']) == ('E1003', 'nodes.aji', 2), record
assert record['type'].endswith('N0'), record
print(f'nominal query CLI integration passed ({checks} checks)')