Skip to content

fix(tcl): default-value braced-pair parameters overcounted in args - #1539

Merged
squid-protocol merged 1 commit into
mainfrom
fix/tcl-1512-default-value-brace
Aug 14, 2026
Merged

fix(tcl): default-value braced-pair parameters overcounted in args#1539
squid-protocol merged 1 commit into
mainfrom
fix/tcl-1512-default-value-brace

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Fixes #1512.

Summary

Tcl's default-value parameter syntax, {paramName defaultValue} as a single braced pair inside the outer argument-list braces (e.g. proc faultsim_integrity_check {{db db}} { ... }), was measured as 2 parameters instead of 1. Root cause: detector.py's _calculate_block_metrics fell through to a naive whitespace .split() for any comma-free args string, splitting {db db} into two tokens instead of recognizing the braced pair as one Tcl-list unit.

Fix: new depth-aware _count_tcl_arg_list walk (mirrors the existing haskell pattern-list counter precedent from #1505) -- a {...} span at depth 0 counts as one parameter, bare tokens count as one each. Pure Python string-walking, no regex/ReDoS surface change.

Numbers

language-crucible/data/tcl/sqlite/tester.tcl and others: args_exact_match 119/142 -> 142/142 (100%). found_functions/extra_functions unchanged (no side effects).

Test plan

  • pytest tests/extraction/languages/test_tcl.py tests/extraction/languages/test_tcl_strict.py -- 107 passed
  • tree_sitter_accuracy_audit.py --lang tcl -- no regressions, all mismatch samples now empty
  • ruff check -- no new findings on touched code

🤖 Generated with Claude Code

#1512: Tcl's default-value parameter syntax {paramName defaultValue} (a single
braced pair inside the outer argument-list braces, e.g. proc foo {{db db}})
was counted as 2 tokens instead of 1. Root cause was in detector.py's
_calculate_block_metrics fallback (naive whitespace .split() for any comma-free
args string), not the regex capture itself -- fixed with a depth-aware token
walk (_count_tcl_arg_list) mirroring the existing haskell pattern-list counter's
precedent (#1505): a {...} span at depth 0 is one token, bare tokens are one
each. No regex/ReDoS surface change.

Verified against language-crucible/data/tcl/sqlite/tester.tcl: args_exact_match
119/142 -> 142/142 (100%), found_functions/extra_functions unchanged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@squid-protocol
squid-protocol merged commit 22562b2 into main Aug 14, 2026
24 of 27 checks passed
@squid-protocol
squid-protocol deleted the fix/tcl-1512-default-value-brace branch August 14, 2026 02:37
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

squid-protocol added a commit that referenced this pull request Aug 14, 2026
…sequence (#1545)

PR #1539 (tcl fix) was built against main before PR #1538 (dart fix) merged,
so its own crucible-audit CI ran against a stale base and correctly flagged
drift -- but auto-merge proceeded anyway since crucible-audit isn't a required
check, landing tcl's fix without its golden masters reflecting dart's already-
merged changes. This blesses main's actual current combined state (both fixes
applied) rather than a snapshot of either fix in isolation. No code change.

Co-authored-by: Joe Esquibel <squid-protocol@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
squid-protocol added a commit that referenced this pull request Aug 14, 2026
* fix(python): args regex only balanced one level of nested parens

#1527: python's args rule's parameter-list capture group
\((?:[^()]|\([^()]*\))*\) balances exactly one level of nested parens (outer
paren + one inner non-nested group). A default value with two levels of
nested calls -- FastAPI's dependency-injection idiom
Depends(partial(callable_gen_dependency, "x")) -- doesn't match at all, so
the whole def statement is skipped and args silently defaults to 0.

Extends the existing bounded-recursion idiom by one more level (still no
unbounded backtracking -- same ReDoS-safety tradeoff already established for
this rule, just deeper). Confirmed 12 occurrences of this exact shape in
language-crucible/data/python/fastapi/tests/test_dependency_partial.py.

args_exact_match: 3588 -> 3601 (python corpus), no other metric changed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* chore: regenerate baselines against post-dart/tcl/bless main

Rebased this branch onto the current main (after #1538/#1539/#1545 merged)
and regenerated the target's own tree-sitter baseline, both golden masters,
and the ruff line-shift baseline against the combined state. No additional
code change beyond the previous commit.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Joe Esquibel <squid-protocol@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
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.

tcl args regex: default-value braced parameters overcounted (proc foo {{db db}} measures got=2, real=1)

1 participant