fix(dart): stop treating try/finally blocks as function declarations (#1622) - #1673
Closed
uuzzrm wants to merge 3 commits into
Closed
fix(dart): stop treating try/finally blocks as function declarations (#1622)#1673uuzzrm wants to merge 3 commits into
uuzzrm wants to merge 3 commits into
Conversation
…quid-protocol#1631) func_start's colon-annotated-arrow branch cannot distinguish a real arrow-function property from a parameter's function-type annotation -- both are `IDENT: (...) => ...` on the surface. A nested parameter (`f: (a: A) => B` inside an interface member's own signature, e.g. fp-ts pipeable.ts's `f`/`g` phantoms) is always the first thing after an already-open parameter list, so its line is directly preceded by `(`; an object-literal arrow property is never (its enclosing `{` is). Dropping line-anchored matches whose preceding non-whitespace char is `(` removes the phantom parameter annotations without touching real arrow-function properties. Measured against language-crucible/data/typescript: - extra_functions: 299 -> 275 (24 phantom parameter annotations removed) - found_functions: 1876 -> 1876 (zero recall loss) - args_exact_match: 1796 -> 1796 (unchanged) - javascript: no regressions (found 599, extra 11 unchanged) Golden masters re-blessed via update_golden_master.py (the phantom function entries are gone from the corpus snapshots); both crucible modes pass. Closes squid-protocol#1631. Signed-off-by: Ruiming Zhao <uuzzrm@gmail.com>
Resolves the generated-file conflict from merging origin/main (which had just picked up squid-protocol#1655's typescript brace-less-arrow fix) into this PR's branch -- standard parallel-PR conflict resolution: took main's version of the generated files, then regenerated fresh on the merged code.
…quid-protocol#1622) Signed-off-by: Ruiming Zhao <uuzzrm@gmail.com>
Owner
|
Same fix, independently arrived at -- both add `try|finally` to the same 6 occurrences of the exclusion list. This is already up as #1664 (open, same diagnosis and fix shape), so closing this one as a duplicate to avoid two competing PRs on the same regex region. Nothing wrong with this PR -- just landed a few minutes behind. |
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.
What & why
Closes #1622.
Dart's
tryandfinallykeywords at line start were misdetected as phantom zero-arg function declarations: thefunc_startregex's negative-lookahead keyword exclusions coveredclass|mixin|enum|extension|typedef|if|for|while|switch|catch|case|when|assert|return|throw|new|var|final|constbut nevertryorfinally— sotry {/finally {matched as a function literally named "try"/"finally". Confirmed via the issue's repro againstlanguage-crucible/data/dart/flutter/*.dart: 38 spurious "try" rows infunction_data, ~9% of dart's remainingfunc_startfalse-positive rate.The fix
Add
try|finallyto the keyword-exclusion lookaheads in all threefunc_startalternatives (6 exclusion sites ingitgalaxy/standards/language_standards.py). A real method namedtryMethodstill matches; only the reserved keywords are rejected.Measured effect (tree-sitter accuracy audit, pinned corpus)
Zero recall loss, no regressions. Golden-master fixtures re-blessed via
update_golden_master.py(both modes); the drift is confined to dart entries plus the usual sub-epsilon float drift from the shared spatial layout recomputing on the changed graph.Test plan
tests/extraction/languages/test_dart.py:try {,finally {, indented variants.pytest tests/extraction/languages/test_dart.py test_dart_strict.py→ 190 pass.tree_sitter_accuracy_audit.py --lang dart→ no regressions (baseline re-blessed: extra 186→149).ruff_audit.py --ci: no new findings;dead-key-audit/ast-accuracy-auditclean.