cli: parse unary prefix chains iteratively
This commit is contained in:
1 parent
fb80413b37
commit
c36b269289
5 files changed
+270
-32
No files matched your search
@@ -0,0 +1,73 @@
|
||||
# Source expression depth audit
|
||||
|
||||
This non-normative audit tracks Q-061 independently of the resolved compiler
|
||||
type-traversal inventory (Q-059). It uses finite generated/public source only;
|
||||
it does not set an expression-depth acceptance limit or report model outcomes.
|
||||
|
||||
## Confirmed baseline failures
|
||||
|
||||
On the Debug CLI preceding the unary-parser repair (code at `fb80413`),
|
||||
`fn main() -> bool effects [] { return not … false; }` accepts 16 prefixes.
|
||||
At 1,024 prefixes, checking aborts in `Lowerer.expr`, with repeated `.not`
|
||||
operand calls. At 16,384 and 65,536 prefixes, it aborts earlier in
|
||||
`Parser.unary`. Each failing check exits by signal (observed return code -6)
|
||||
without a stdout diagnostic. These are observed native-stack failures, not
|
||||
language rejection rules. Stderr reports a segmentation fault at the recursive
|
||||
entry/operand call, followed by repeated native frames of that function.
|
||||
|
||||
The ignored evidence is under `.zig-cache/contract-gate/type-depth/`:
|
||||
`expression-depth-before.json`, `prefix-not-*.stdout` and `prefix-not-*.stderr`.
|
||||
No wall-clock timeout terminates these probes.
|
||||
|
||||
## Unary parser continuations
|
||||
|
||||
The parser records `-`, `not`, `*` and inline borrow prefixes in an explicit
|
||||
pending list, parses the terminal operand and rebuilds the nodes inside out.
|
||||
`move` remains a terminal name form. A borrow still parses its operand through
|
||||
unary only when the next token is `*`; otherwise it uses postfix directly.
|
||||
This preserves the existing place boundary, rather than admitting new spellings
|
||||
such as `ref -value`, `mut not value` or `ref move value`.
|
||||
|
||||
Each rebuilt node retains its own start and the final operand end, including
|
||||
comments, newlines and file provenance. AST node order, operator association,
|
||||
postfix precedence and syntax failure positions are unchanged. Pending metadata
|
||||
is host compiler storage and is released on completion/error. Allocation failure
|
||||
still propagates OutOfMemory; no partial AST escapes, new code or depth rejection
|
||||
is introduced. AIR, verifier ownership/borrow rules, runtime evaluation, fuel,
|
||||
effects and source/reference bundle text are unchanged.
|
||||
|
||||
An independent shallow copy of the old unary derivation checks 448 combinations
|
||||
of prefixes and successful/failed operands. It compares complete ASTs, failure
|
||||
records, token cursors and last-consumed positions. Its shared postfix parser is
|
||||
outside that oracle's scope. Separate tests parse 32,768 mixed prefix groups
|
||||
including borrowed dereferences, inspect every node/span iteratively and check a
|
||||
missing operand at the deepest position. A failing-allocator test covers all
|
||||
arena backing requests in a longer chain, including pending-list growth and
|
||||
output construction, and verifies complete release.
|
||||
|
||||
Syntax-only CLI probes format 1,024/16,384/65,536 `not` prefixes successfully
|
||||
and idempotently, retaining every prefix. Missing-operand checks at
|
||||
16,384/65,536 prefixes emit exactly one E7001 with independently computed
|
||||
line/column and expected/found fields. These do **not** establish successful
|
||||
deep lowering or execution. The permanent `source_grammar.py` suite includes
|
||||
those formatting/diagnostic regressions at all three depths, with the same
|
||||
syntax diagnostic across check/lower/run/report/explore/fmt.
|
||||
|
||||
Validation: build, units and format checks pass; all 1,793 ordinary conformance
|
||||
cases pass with exact unique corpus coverage. Old/new public source checks and
|
||||
successful lowerings are byte-identical (1,423/506). The grammar integration
|
||||
suite passes 312 checks; the formatter suite passes 6,078 checks over 1,469 files
|
||||
(1,414 parsed, 55 syntax-error fixtures, 782 identical successful AIR outputs).
|
||||
These are compiler regressions, not a model-capability measurement or full GC
|
||||
validation.
|
||||
|
||||
## Remaining work
|
||||
|
||||
The confirmed `.not` lowering recursion remains unchanged. Other expression
|
||||
and statement paths, including parenthesized/nested primary parsing,
|
||||
`peekType`/`useIn`, generic `expression`/`walk` and lowering's other recursive
|
||||
expression/block handlers, need separate probes and repairs. Their complete
|
||||
depth behavior is unverified here. The formatter's expression-marking traversal
|
||||
already uses a worklist, as inspected and exercised by the deep syntax-only
|
||||
probes. Q-061 and Phase 6 remain open; Q-060's unfinished full GC validation is
|
||||
independent. No fresh Claude review covers this parser increment.
|
||||
Reference in new issue
Block a user