From a491eba193734b09fca9a9212d5bbe69aa1f1956 Mon Sep 17 00:00:00 2001 From: "A.Shakhmatov" Date: Fri, 9 Oct 2026 18:43:18 +0300 Subject: [PATCH] tests: add nested-size source rejection twins --- docs/plan/phase-6-source-language.md | 6 ++++ tests/conformance/reject-twins.json | 31 +++++++++++++++++++ .../source/reject_twins/nested_size_frame.aji | 15 +++++++++ .../source/reject_twins/nested_size_gib.aji | 11 +++++++ .../source/reject_twins/nested_size_mutex.aji | 12 +++++++ .../reject_twins/nested_size_overflow.aji | 10 ++++++ .../source/size_limits/nested_size_1025.aji | 3 +- .../source/size_limits/nested_size_cycle.aji | 8 +++++ 8 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 tests/conformance/source/reject_twins/nested_size_frame.aji create mode 100644 tests/conformance/source/reject_twins/nested_size_gib.aji create mode 100644 tests/conformance/source/reject_twins/nested_size_mutex.aji create mode 100644 tests/conformance/source/reject_twins/nested_size_overflow.aji create mode 100644 tests/conformance/source/size_limits/nested_size_cycle.aji diff --git a/docs/plan/phase-6-source-language.md b/docs/plan/phase-6-source-language.md index f8569b2..b00187a 100644 --- a/docs/plan/phase-6-source-language.md +++ b/docs/plan/phase-6-source-language.md @@ -329,6 +329,12 @@ Validation: full conformance is 1,713/1,713; unit tests, Zig formatting, all 62 The frontend ordinary-dereference E4202 now adds concrete found and use fields, retaining the code, message, primary position and early failure. CLI tests pass 33 checks; comparison with the previous compiler passes 52, including generic/package provenance, first-error selection, untouched alternative errors and identical valid AIR. No SSA identity or AIR location is fabricated for a frontend rejection. Atomic access invariants, verifier/runtime rules and deterministic execution remain unchanged; valid reads use explicit atomic.load orderings. The schema is additive; the source bundle grows by 30 tokens (docs/agent/README.md). Q-053 remains the owner decision on the literal criterion; there are no unaudited public rows. +## P6-7 nested-size rejection twins (2026-10-09) + +Five Q-058 regression cases now have verified source/AIR twins with identical E5101 budget facts: finite nested value size, one-GiB anonymous content with an unrelated named declaration, mutex wrapper/content, checked-u64 size overflow and a local frame one byte over the limit. The nominal-context pair additionally compares the complete type declarations. Existing markers, canonical/annotated lowering, raw AIR diagnostic projection and independent source coordinates are checked by the regular twin tool. Same-code coverage is 96/205; 45 E7xxx analogues and 63 AIR-only cases remain unmet. + +One row remains pending: nested_size_cycle_overflow.air reports E5101 before finite-layout validation, while the same source declaration necessarily rejects earlier with E1003. A separate source fixture preserves that actual code; it is not falsely linked as an E5101 twin. The current inventory's E7xxx analogue category cannot represent this earlier verifier-code rejection. Q-053's literal completion decision remains open; no rejection rule or diagnostic is changed for coverage. Full conformance passes 1765/1765; sixteen nested-size cases also pass with collection before every instruction. All 62 checker regressions pass, and source construct coverage stays 121/121. No fresh Claude review was available for this increment. P6-7 remains doing. + ## P6-1 source specification consistency (2026-10-09) Spec 15's initial Phase 6A limits now point to its existing extensions. Its introductory diagnostic rule follows §10 and construct-specific codes; widening reports source E7005 while AIR retains E1002, including the corrected Quick Reference entry. Multi-result bindings include complete unpacking, byte escapes agree with the later exact list, and grammar comments locate graph access in §8. Old incremental limits link buffers/borrow returns to §17/§19. No grammar production, semantic rule or implementation changes. Six existing public fixtures confirm the reported code and deterministic successful AIR; Claude independently audited the corrections. The reference bundle rebuilds; source growth is +50/+47/+58 tokens across the three tokenizers, with unchanged Quick Reference token counts, AIR and std (docs/agent/README.md). P6-1/P6-5 remain open for their unimplemented surfaces. diff --git a/tests/conformance/reject-twins.json b/tests/conformance/reject-twins.json index e8a46e1..30eebad 100644 --- a/tests/conformance/reject-twins.json +++ b/tests/conformance/reject-twins.json @@ -1732,6 +1732,37 @@ "kind": "air_only", "spec": "docs/spec/15-source-language.md \u00a74", "rule": "The AIR regression passes a lent task as switch target arguments. Source integer/enum match arms have no target arguments; changing variables reach a subsequent br join. A later-merge E4302 would discard the switch-handoff context being tested." + }, + "phase1/reject/nested_size_frame.air": { + "kind": "same_code", + "site": "function", + "spec": "docs/spec/08-verifier.md \u00a77.1", + "rule": "A one-MiB nested array and one byte both need frame storage. The source and AIR retain identical limit/max/found/type facts." + }, + "phase1/reject/nested_size_gib.air": { + "kind": "same_code", + "site": "function", + "spec": "docs/spec/08-verifier.md \u00a77.1", + "rule": "An unrelated nominal type cannot truncate anonymous array accounting. The source and AIR retain identical limit/max/found/type facts.", + "match_type_declarations": true + }, + "phase1/reject/nested_size_mutex.air": { + "kind": "same_code", + "site": "function", + "spec": "docs/spec/08-verifier.md \u00a77.1", + "rule": "Mutex accounting includes its content and the eight-byte wrapper. The source and AIR retain identical limit/max/found/type facts." + }, + "phase1/reject/nested_size_overflow.air": { + "kind": "same_code", + "site": "function", + "spec": "docs/spec/08-verifier.md \u00a77.1", + "rule": "Anonymous nested-array arithmetic retains checked-u64 overflow. The source and AIR retain identical limit/max/found/type facts." + }, + "phase1/reject/nested_size_value.air": { + "kind": "same_code", + "site": "function", + "spec": "docs/spec/08-verifier.md \u00a77.1", + "rule": "A parameter of array,1025> accounts 1049600 bytes in both artifacts, preserving the complete value-size budget facts." } } } diff --git a/tests/conformance/source/reject_twins/nested_size_frame.aji b/tests/conformance/source/reject_twins/nested_size_frame.aji new file mode 100644 index 0000000..5bc83d0 --- /dev/null +++ b/tests/conformance/source/reject_twins/nested_size_frame.aji @@ -0,0 +1,15 @@ +// A one-MiB nested array and one byte both need frame storage. +// expect: reject E5101 +// phase: 6 +// spec: docs/spec/08-verifier.md §7.1; docs/spec/15-source-language.md §10 +// AIR twin: phase1/reject/nested_size_frame.air +module test.twins.nested_size_frame + +fn unused() -> void effects [] { // diagnostic here: fn unused + var a: [[u8; 1024]; 1024] = zero; + var b: u8 = zero; + ref av = a; + ref bv = b; +} + +fn main() -> void effects [] {} diff --git a/tests/conformance/source/reject_twins/nested_size_gib.aji b/tests/conformance/source/reject_twins/nested_size_gib.aji new file mode 100644 index 0000000..4f43cc5 --- /dev/null +++ b/tests/conformance/source/reject_twins/nested_size_gib.aji @@ -0,0 +1,11 @@ +// An unrelated nominal type cannot truncate anonymous array accounting. +// expect: reject E5101 +// phase: 6 +// spec: docs/spec/08-verifier.md §7.1; docs/spec/15-source-language.md §10 +// AIR twin: phase1/reject/nested_size_gib.air +module test.twins.nested_size_gib + +struct Unused { n: u8 } +fn unused(data: [[[u8; 1024]; 1024]; 1024]) -> void effects [] {} // diagnostic here: fn unused + +fn main() -> void effects [] {} diff --git a/tests/conformance/source/reject_twins/nested_size_mutex.aji b/tests/conformance/source/reject_twins/nested_size_mutex.aji new file mode 100644 index 0000000..964bac9 --- /dev/null +++ b/tests/conformance/source/reject_twins/nested_size_mutex.aji @@ -0,0 +1,12 @@ +// Mutex accounting includes its content and the eight-byte wrapper. +// expect: reject E5101 +// phase: 6 +// spec: docs/spec/08-verifier.md §7.1; docs/spec/15-source-language.md §10 +// AIR twin: phase1/reject/nested_size_mutex.air +module test.twins.nested_size_mutex + +fn unused(data: mutex<[u8; 1048576]>) -> mutex<[u8; 1048576]> effects [] { // diagnostic here: fn unused + return move data; +} + +fn main() -> void effects [] {} diff --git a/tests/conformance/source/reject_twins/nested_size_overflow.aji b/tests/conformance/source/reject_twins/nested_size_overflow.aji new file mode 100644 index 0000000..306d18e --- /dev/null +++ b/tests/conformance/source/reject_twins/nested_size_overflow.aji @@ -0,0 +1,10 @@ +// Anonymous nested-array arithmetic retains checked-u64 overflow. +// expect: reject E5101 +// phase: 6 +// spec: docs/spec/08-verifier.md §7.1; docs/spec/15-source-language.md §10 +// AIR twin: phase1/reject/nested_size_overflow.air +module test.twins.nested_size_overflow + +fn unused(data: [[[u64; 4294967296]; 4294967296]; 1]) -> void effects [] {} // diagnostic here: fn unused + +fn main() -> void effects [] {} diff --git a/tests/conformance/source/size_limits/nested_size_1025.aji b/tests/conformance/source/size_limits/nested_size_1025.aji index b6012a8..7cfecf6 100644 --- a/tests/conformance/source/size_limits/nested_size_1025.aji +++ b/tests/conformance/source/size_limits/nested_size_1025.aji @@ -2,6 +2,7 @@ // expect: reject E5101 // phase: 6 // spec: docs/spec/08-verifier.md §7.1; docs/spec/15-source-language.md §10 +// AIR twin: phase1/reject/nested_size_value.air module nested_size -fn unused(data: [[u8; 1024]; 1025]) -> void effects [] {} +fn unused(data: [[u8; 1024]; 1025]) -> void effects [] {} // diagnostic here: fn unused fn main() -> void effects [] {} diff --git a/tests/conformance/source/size_limits/nested_size_cycle.aji b/tests/conformance/source/size_limits/nested_size_cycle.aji new file mode 100644 index 0000000..c4dac5d --- /dev/null +++ b/tests/conformance/source/size_limits/nested_size_cycle.aji @@ -0,0 +1,8 @@ +// Source declaration validation rejects the by-value cycle before AIR budgets. +// This is not a same-code twin of nested_size_cycle_overflow.air (E5101). +// expect: reject E1003 +// phase: 6 +// spec: docs/spec/15-source-language.md §1 +module test.nested_size_cycle +struct A { n: u8, x: [A; 4294967296] } +fn main() -> void effects [] {}