Skip to content

lint: recurse W002 into unobserved blocks and match arms - #793

Merged
InauguralPhysicist merged 1 commit into
InauguralSystems:mainfrom
Nitjsefnie-OSC:fix/lint-w002-unobserved-match-781
Aug 2, 2026
Merged

lint: recurse W002 into unobserved blocks and match arms#793
InauguralPhysicist merged 1 commit into
InauguralSystems:mainfrom
Nitjsefnie-OSC:fix/lint-w002-unobserved-match-781

Conversation

@Nitjsefnie

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #781. check_unused_params recursed only through AST_IF/FUNC/FOR/PROGRAM and kept both AST_MATCH and AST_UNOBSERVED in its break-only group, so a define nested in an unobserved: block or a match arm was never visited and the W002 emission was never reached.

Both arms were missing here, so this adds both — unlike #790, where the walker already recursed AST_UNOBSERVED and only AST_MATCH was needed. The recursion idiom is #787's for the same node types, verbatim.

Changes

Testing

  • bash tests/test_lint.sh run directly for its exit code: 123 passed, 0 failed, 123 total, exit 0.
  • Full suite tests/run_all_tests.sh: RESULTS: 3315/3315 passed, 0 failed.
  • Both reproducers from the issue go from silent to warning; the control still warns exactly once.
  • The tests bite. With src/lint.c reverted to upstream and the new tests kept, both behaviour tests fail (121 passed, 2 failed). The third test passes against unfixed code, which is what a regression pin should do.
  • Neither arm is dead. Deleting AST_MATCH alone silences the match reproducer while unobserved: still warns; deleting AST_UNOBSERVED alone is the exact mirror.
  • Verified against the merge result, not just the branch: rebased onto current main (1750b48, which now includes lint: recurse W001 collect_assigns into match arms #790), builds clean, tests/test_lint.sh exit 0.

One caveat stated plainly, because it is easy to over-read. Linting all 397 .eigs files under lib/ + examples/ + tests/ with the unfixed and fixed binaries produces byte-identical output (112,051 bytes, 973 warnings, per-file exit codes included). That is a no-regression result and nothing more: an indentation-aware scan finds zero defines nested inside unobserved: or match anywhere in that corpus, so even a no-op arm would have produced the same bytes. The two new tests are the only evidence the fix actually fires. fuzz/corpus/ was deliberately outside that scope.

Checklist

  • make test passes locally — full suite via tests/run_all_tests.sh: 3315/3315 passed, 0 failed; lint tests run directly for their exit code, 123 passed, 0 failed, exit 0
  • New builtins have signature comments and docs in docs/BUILTINS.md — n/a, no new builtins
  • New library functions follow conventions in docs/STDLIB.md — n/a, no new library functions
  • New examples have a comment header explaining what they demonstrate — n/a, no new examples
  • CHANGELOG.md updated (if user-facing change) — not done, following the two merged precedents for this fix family: lint: recurse W012/W013 into unobserved blocks and match arms #787 and lint: recurse W001 collect_assigns into match arms #790 each changed only src/lint.c and tests/test_lint.sh. Happy to add an entry if you'd rather these carried one.

Generated by Claude Opus 5 (brief, review), Kimi K3 (implementation, verification)

…ch arms

check_unused_params recursed only through IF/FUNC/FOR/PROGRAM, breaking
on AST_UNOBSERVED and AST_MATCH, so a define inside an unobserved block
or a match arm never had its parameters checked and W002 lint'd clean
while the same unused parameter at top level warned. Recurse into both,
matching the shape check_builtin_shadow (InauguralSystems#787) and collect_assigns
(InauguralSystems#790) already use for these node types. Diagnostics themselves are
unchanged.

Closes InauguralSystems#781

Co-Authored-By: Kimi K3 <noreply@kimi.com>
@InauguralPhysicist
InauguralPhysicist merged commit 01e0a77 into InauguralSystems:main Aug 2, 2026
16 checks passed
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.

lint: W002 (unused parameter) never fires for a function defined inside unobserved: or a match arm

2 participants