Repository navigation
analyze: audit:resolution phase 1 — every MIR callee agrees with Sema's resolution (D65, #1647); validate-all rejects a signature-less const-fn callee (#1639) - #1662
Conversation
9ec7b68 to
3ff4208
Compare
|
Full Findings the sweep surfaced along the way, each resolved by a producer stating its fact (no exclusion, no name list): |
…nt agrees with Sema's resolution of the call it lowers (D65, #1647) For each MIR call terminator the audit gathers Sema's answer for the call's own AST node and compares it with what MIR resolved, re-deriving nothing: a `const fn` callee must be a declared signature, a generic template under its GENERIC_CALL mark, a builtin Sema classified, or a body of the module; a place callee must be a call Sema resolved through a callable value; the argument count must equal that same fact's parameter count (a variadic signature or an extern fn type states none); a call node Sema resolved to one signature must not lower to another; and a call Sema resolved inside a lowered body must have a MIR call fact carrying its node. Any other intrinsic mark is recognized by its kind. Each violation names the body, the node's path:line:column, MIR's answer, Sema's answer and the rule; the same rows are Invariant facts. Facts Sema now emits (one owner per fact): `call_callable_types`, the callable type an indirect call invokes, recorded once in check_call for a callable binding, a callable field and any other callable-typed callee (#1635's `let r = c.run; r(21)` is a Callable answer where MIR called a function named `r` with the argument dropped); `intrinsic_fn_syms` / `generic_builtin_syms`, the builtins is_intrinsic_fn_sym and the type-argument predicates accept, enumerated; `call_callee_is_builtin`, Sema's classification of a call node's callee. MirModule carries them as `sema_callable_syms` (keyed by its own pool, carried by name) for the validator that follows. `math_fn_count` exposes the math table's size. A desugared combinator (`opt.map(f)`, `res.or_else(f)`, `filter`) invokes an argument's value and carries the combinator call as its node; the callable Sema typed that argument with is the callee's fact (behav_c_facade_getenv_twice.w; the compiler never calls Option.map with a closure, so only the fixture exercised it). The comparison (mir_resolution_check_call, MirCore) takes Sema's answer as a record, so a planted body and a planted answer exercise the rule without a Sema. `audit:resolution` is in `audit:all`. Two shapes MIR materializes without a call fact, judged from the facts their producers already hold: a language-machinery GENERIC_CALL (a Task/ScopedTask/channel/Atomic method, `track`, `spawn`, `join`) carries the dispatch mark MirLower's one contract decision point (require_generic_call_contract) now sets — codegen dispatches those by name and receiver, and #1635's unresolved-bare-function branch never sets it (phase 5 moves that classification into Sema and retires the mark); an explicit `x.drop()` Sema resolved to the type's Drop impl is the drop operation, recognized by the `drop` method symbol, type_has_drop_impl on the receiver and no argument — the same facts MirLower's drop-glue gate reads (behav_arena_region.w, behav_arena_vec.w). Corpus: audit:resolution violations=0 on src/main.w, build.w, the contract fixtures and every test/behavior fixture that analyzes; audit:all violations=0 on the #1635 and getenv_twice fixtures.
… Sema knows and carries no intrinsic mark (#1639, D65) #1635's MIR — a GENERIC_CALL to a symbol named after a callable binding, the source argument dropped — passed every validator and died in codegen. The typed-MIR validator now refuses a `const fn` callee that is not in the module's `sema_callable_syms` snapshot (Sema's declared signatures, generic templates and builtins, propagated at lowering), has no body in the module and carries no intrinsic mark other than GENERIC_CALL; a NONE-marked direct call to a template or builtin is refused too, since the GENERIC_CALL mark carries its concrete contract. No builtin is named here: the snapshot is Sema's fact. The two planted bodies that called a bodiless symbol 2 through this validator (#1180 Unit argument, #1443 missing borrow) declare it as a signature, which is what they always meant. A GENERIC_CALL that carries a recorded contract (sig or mono), or the machinery-dispatch mark from require_generic_call_contract, is accounted for: `s.track(t1)` and `Atomic.new` lower that way and the first build of this rule refused every async-scope and Atomic program. The planted matrix covers the mark: marked GENERIC_CALL ok, the same MIR without it refused.
…-callee validator (#1647, #1639) mir_test_resolution_callees: the comparison over a hand-built body and a hand-built Sema answer — #1635's shape (a function invented from a binding's name), a callee Sema knows nothing about, an argument count that disagrees with the signature or the callable type (#1639's silent case), a call node resolved to one signature and lowered to another, a template or builtin without its GENERIC_CALL mark, and the clean cases. mir_test_unknown_callee: the validator's matrix over intrinsic mark × snapshot class × body presence. The compiler no longer produces these from source, so they are planted the way test/internals plants MIR.
…esolution joins to them (D65, #1647) Rule 5 — a call Sema resolved inside a lowered body has a MIR call fact — met three MIR-owned materializations that left no fact and no trace: `for x in v.iter()` and a comprehension over it are the index loop (`.iter()` is the implicit form, §13); a typed `BTreeMap.new()` / `BTreeSet.new()` is the aggregate built in place of its resolved specialization; a static `HashMap.new()` is MAP_NEW with no node. MIR now states each: `MirBody.elided_call_nodes` records the peeled `.iter()` (lower_for and the comprehension) and the btree `new`; the intrinsic method emission carries its call node. The audit joins Sema's resolved node to a call fact or a stated elision and reports the counts; a call that vanished with neither is still red. behav_comprehension_view_to_fn.w (4), behav_d61_debug_rows.w (2), behav_for_iter_mut_self.w and behav_for_binding_disjoint_mutation.w were the corpus findings; violations=0 on each, on src/main.w and on build.w.
3ff4208 to
d95194a
Compare
LLDB on fold2 d95194a's release binary, analyzing the one-line indirect c_va_list callback with audit:resolution --no-prelude, stops in resolution_sorted_by_key: the input Vec header has len=1; at +356, w20=1 (n), w10=w12=w13=0xffffffff (root, child, r), and w15=0xfffffffe. Single-stepping tbnz w15,#31 enters the bounds-panic block at +1016. The source is AnalysisResolution.w's keys[order[child]] comparison: n / 2 - 1 initialized root to -1 before the unconditional sift loop. Return the already ordered indices for n < 2. Keep the audit's verdict checks intact. Add a no-prelude regression covering the no-MIR diagnostic, the singleton indirect callback, and two declaration spans. The old release compiler fails the singleton case with panic: index out of bounds.
|
Stack #1664 validation at
The blocker was in the resolution audit's heap sort, not a prelude-sized Sema table. LLDB observed a one-element vector, Local logs: The tested stack descends from 1814a14. Main has since advanced to aa978c6 with the UAT specification/inventory changes; run the required main battery after merge before installing or cutting the next seed. The seed accommodation in #1661 remains until that seed cut. The separate tally example safety gate remains tracked by #1644/#1643. The existing three layers are ready. Eric has now prioritized #1665; that fix will be added as the next GitHub stack layer and receive combined verification before the merge. |
Adds
with analyze <file> audit:resolutiontoaudit:all(D65, #1647). Each MIR call is checked against Sema's recorded callee and argument count; resolved calls inside lowered bodies must be accounted for. Violations identify the body, source location, and disagreeing facts.--validate-allalso rejects a signature-less const-fn callee outside Sema's callable snapshot (#1639).Sema produces callable, intrinsic, and generic facts; MIR propagates them to the validator. The audit reads those facts, including callable arguments of desugared combinators, Drop-impl calls materialized as drops, and calls MIR explicitly records as elided. It does not introduce a callee-name allow-list.
Planted MIR/Sema fixtures cover unknown and invented callees, direct and indirect arity mismatches, node/signature disagreements, and missing generic/intrinsic dispatch marks. A no-prelude regression covers the no-MIR diagnostic, one indirect callback body, and two declaration spans.
The first stack battery passed build, fixpoint, drop-audit, and move-audit, but found a singleton-input panic in the resolution audit. LLDB proved
resolution_sorted_by_keyinitialized root to -1 for one span and entered theorder[child]bounds-panic branch. The sorter now returns immediately for fewer than two entries; audit checks remain intact. The new regression fails on the previous release binary with that panic.Part 3 of the GitHub stack: #1656 → #1661 → #1662. #1661 contains the temporary source accommodation needed to build with the pinned seed, which still carries the field-path packing bug. Remove that accommodation after the next seed cut.
Validation at 974c8ba: full seed-driven build, fixpoint (16 units), drop audit (213 cells), move audit (105 cells), full test suite, test-green, and last-green all passed. The suite includes 1,273 behavior files and all 36 internal-test files. The final verdict table is posted below. Earlier iterate checks and the 1,218-fixture resolution sweep also passed.