Repository navigation
dag grammar: arrow-lambda bodies may be an unbraced let-headed statement sequence - #13182
Merged
Merged
Conversation
…ence that begins with a let '(r) =>' then 'let slug = f(r)' then the value, ending at the call's ')' or ',', refused the parse in eight corpus files. The body is now a choice between lambda_stmt_body (a let-headed statement spine) and the expression, disjoint by the let-sugar head guard the expression statement already carries. The one decoder (fold_lowering fv_arrow_body) classifies it as FunctionLiteralStatementBody, which lowers through the statement spine like every statement sequence. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…t, roster file untouched The prepared grammar's FIRST row for stmt holds let and neither ',' nor ')', and a value-position lambda whose unbraced body is followed by the next argument normalizes. The arrow_lambda_block_body RFM row records the decoder's third arm. The floor_pure_producer_share comment edit is reverted (warm-row freeze): alb_verdicts keeps its enrolled identity. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An arrow lambda's body may now be an unbraced statement sequence that begins with a
let:Before, the body after
=>was read only as an expression, so theletrefused the parse in 8 corpus files.Grammar (
v2.extdeps.languages.dag)dag_grammar_arrow_lambda_body_expr: after=>, a lambda body is one of two disjoint alternatives:lambda_stmt_body:lambda_let_stmt stmt*. Its head is a statement whose captured child is alet_expr: theletform or either let sugar.dag_grammar_let_sugar_head_expr. This is the same guard the expression statement already carries.letitself begins no expression.,or), so the statement repetition stops where the enclosing argument list continues. This is the disjoint end the ruling asked for.Classification (
v2.compiler.fold_lowering)The one decoder is
fv_arrow_body, which wrapsfv_block_body_optional. It now answers three kinds:FunctionLiteralStatementBody { body }forlambda_stmt_body;FunctionLiteralBlockBodyfor a bracedfn_body;FunctionLiteralExprBodyotherwise.The statement body's captured child is the statement spine. So
body_lower_function_value_bodylowers it withbody_lower_stmt_seq, the same authority a fn body and a match-arm statement body use: a let binds the rest and the last statement is the value. The fold step reads it viafold_step_body, and the exit walk treats it likematch_arm_stmt_body.Controls
All are in
v2.test.claim.body_lowering.arrow_lambda_block_body, beside the existing block-body ones and in the same warm producer:dag/std/graph.dagbuild_adjacency_viewsverbatim: normalizes, and takes the statement route, asserted twice:lambda_stmt_body;arrow_lambda_parts_optionalanswersFunctionLiteralStatementBody;Corpus
Each file was run through the v2 front end:
v2.lens.enforcement.grammar_coveragegrammar_coverage_ingest_path, which reads the real file and runs tokenize, parse and normalize. Main and this branch ran with the same binary in one remote dispatch:dag/test/claim/v1_complexity_capability_census_witness_test.dagparse_declaration_marker_not_testdag/test/claim/witness_row_cost_projection_witness_test.dagparse_g0_tokens_remaindag/std/orthogonal_geometry.dagparse_g0_tokens_remaindag/std/graph.dagparse_g0_tokens_remaindag/gunbc/emit_copy_qualification_fixture_gen.dagparse_g0_tokens_remaindag/gunbc/emit_copy_qualification.dagparse_g0_tokens_remaindag/gunbc/instruments/emit_copy_qualification_transport.dagparse_g0_tokens_remaindag/gunbc/instruments/opaque_realization_census.dagparse_g0_tokens_remainAll 8 files in the corpus that have the shape (
=>at end of line, then a let head) are measured.The body ends disjointly inside call arguments
stmt*.no_statement_begins_with_a_comma_or_a_close_paren_holdsreads the prepared grammar's own FIRST row forstmt, the authority the choice proofs read. It holdsletand neither,nor), so the body stops where the argument list continues, not by order.lambda_stmt_body| guarded-expression choice is in the overlap roster, which measures 0 rows at this head.value_arrow_statement_body_ends_at_the_next_argument_holdsends at,(apply(g: a => let b = a + 1 / b, v: v)).graph_adjacency_real_site_*andfold_step_arrow_unbraced_statement_body_lowers_holdsend at).Prefix table (not landed)
The once-per-grammar 2-prefix table (ruling A) was tried and measured +6%: prepare fill 8.4s vs 7.9s, 4 runs, same binary, with all 63 controls and both rosters (dag, python) identical. It was dropped.
Floor note
alb_verdictsnow computes ten verdicts instead of five. It stays the same identity already enrolled warm (v2.test.claim.body_lowering.arrow_lambda_block_body.alb_verdicts).floor_pure_producer_share.dagis not edited, because of the warm-row freeze until #13043.Failure-mode row
arrow_lambda_block_body_read_as_an_expressiongains a receipt that the one body-kind decoder (fv_arrow_body) has a third arm, and citesfv_arrow_bodyin its evidence.🤖 Generated with Claude Code