Skip to content

fix(rules): length does not measure a list-literal table - #398

Merged
ngngardner merged 1 commit into
mainfrom
fix/length-list-table
Nov 16, 2026
Merged

ngngardner merged 1 commit into
mainfrom
fix/length-list-table

Conversation

@ngngardner

Copy link
Copy Markdown
Contributor

What

length (S010) no longer measures a def whose body is one [..] list of data and nothing else. #381 exempted a table written as a match; this is the same table written as a list:

def table() -> List<&2, Ref>:
  [
    Ref{"AElig", 198, 0},
    Ref{"AElig;", 198, 0},
    ...
  ]

Data is numbers, strings, chars, commas, capitalized and dotted names (a constructor's, or a def named and not called) and [..] and {..} groups of them.

Why

ezhttp's src/entities.bend table is the HTML Standard's 2231 named character references, generated, 2234 lines. length reported it as an error, and the only edit that silenced it was cutting the list into arbitrary chunks. That has no step to move into a helper and fails the honest-fix test src/README.md sets for a rule, exactly as #381 found for match tables.

What is still measured

A plain lowercase name anywhere in the list (a variable, or a call's head such as f(x)), an operator (so -1 and a + b), a keyword, a (..) group, a token after the ] ([..] ++ more), or a line under the statement makes the def no table, and it is measured as before. A second statement in the body still makes any def no table. arity and depth are unchanged.

Checked on a sample file: a 53-line list of R{"n", 1, 0} rows is not reported; the same list with f(i) in each row, and the same list followed by ++ [], are.

Laws

laws/SizeReportsOversizedDefs.bend, prose extended to name the list-of-data table; two law-side definitions, literal (the token kinds data holds) and bracket ([ or {), state the data set independently of the code.

law kind
table_takes_data_list: one statement holding a [ list of data, nothing under it, is a table direct
table_list_needs_data: a list holding what is not data (a call, a match) is no table frame
table_list_holds_nothing_under: a list with a line under it is no table frame
table_list_is_whole_statement: a list with a token after its ] (no :) is no table frame
data_reads_token: a token is data exactly when its kind is literal, and what follows is data direct, both directions
data_reads_group: a group is data exactly when it opens with [ or { and holds and is followed by data direct, both directions
data_rejects_statement: a statement among the elements is no data frame

length_skips_table, length_measures_other_def and size_counts hold as stated, since they are stated over table and the measure. No new trusted assumption. Still not proved, as before: that no comment or string changes a finding of these rules.

Behavior change

Yes: length reports fewer defs (generated data lists). A project with a # noqa: S010 on such a list will see noqa (S005) report it as silencing nothing.

Checks

  • bend PROOF.bend --check-only (bend 2.0.40): ALL PROOFS CHECK
  • nix flake check -L: passes (proofs 2/2 PROOF.bend ok, lint 0 errors / 32 warnings as on main, fmt, lsp)
  • bolt from this branch on ezhttp src/entities.bend: clean; bolt 1.65.0 (dfb06d0) reports S010: Def table is 2234 lines long

🤖 Generated with Claude Code

A def whose body is one `[..]` list of data and nothing else is a table,
as a `match` of one-statement arms is since #381: a generated list of
records, such as ezhttp's src/entities.bend `table` (the HTML Standard's
2231 named character references, 2234 lines). Its length is how many rows
there are, and the one edit that silenced `length` was to cut the list in
two at some line, which helps no reader.

Data is numbers, strings, chars, commas, capitalized and dotted names and
`[..]` and `{..}` groups of them. A plain lowercase name (a variable or a
call's head), an operator, a keyword, a `(..)` group, a token after the
list's `]` or a line under it makes the def no table, and it is measured
as before.

laws/SizeReportsOversizedDefs.bend: `table_takes_data_list`,
`table_list_needs_data`, `table_list_holds_nothing_under`,
`table_list_is_whole_statement`, `data_reads_token`, `data_reads_group`
and `data_rejects_statement` are new; the prose names the new table.
`length_skips_table` and `length_measures_other_def` hold as stated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ngngardner
ngngardner enabled auto-merge (squash) November 16, 2026 16:18
@ngngardner
ngngardner merged commit a49f2f1 into main Nov 16, 2026
4 checks passed
@ngngardner
ngngardner deleted the fix/length-list-table branch November 16, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants