fix(typescript): rule out ternary true-branch in object-method branch - #1657
Merged
squid-protocol merged 3 commits intoAug 15, 2026
Merged
Conversation
… (issue squid-protocol#1632) func_start's object-literal-method branch matches `IDENT :` followed by a function/arrow -- but a ternary's true branch (`cond ? name : function() { ... }`, jquery/deferred.js:182-184) has the identical `name :\nfunction() {` surface while `name` is a plain identifier reference, not an object key. GitGalaxy reported a phantom `mightThrow` at the anonymous function. A real object/namespace key is never preceded (skipping whitespace/ newlines) by `?` -- that position is exclusively the ternary true-branch -- so a bounded backward scan for the preceding non-whitespace char rules the shape out, the same way squid-protocol#1221's Invocation Shield rules out bare call statements. JavaScript and TypeScript share the branch, so the gate covers both. Measured against language-crucible: - typescript: found 1876, extra 299, args 1796 -- unchanged (no regression) - javascript: extra_functions 11 -> 10 (the jquery/deferred.js phantom is gone), found 599 unchanged - repro from the issue now yields zero satellites Golden masters re-blessed via update_golden_master.py; both crucible modes pass. Closes squid-protocol#1632. Signed-off-by: Ruiming Zhao <uuzzrm@gmail.com>
# Conflicts: # gitgalaxy/core/detector.py # tests/golden_master_audit.json # tests/golden_master_zero_dep_audit.json # tests/ruff_audit_baseline.json
Merged origin/main (which had just picked up squid-protocol#1654's and squid-protocol#1655's typescript fixes) into this PR's branch -- both squid-protocol#1654 and this PR's squid-protocol#1632 fix insert a guard at the identical anchor point in _slice_by_braces's per-match loop, so detector.py needed a manual merge combining both guard blocks in sequence (order between them doesn't matter, each is an independent early-continue). Re-blessed golden masters + ruff baseline on the merged code.
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 #1632. func_start's object-literal-method branch matches
IDENT :followed by a function/arrow - but a ternary's true branch (cond ? name : function() { ... }, jquery/deferred.js:182-184) has the identicalname :\nfunction() {surface whilenameis a plain identifier reference, not an object key. GitGalaxy reported a phantommightThrowat the anonymous function.A real object/namespace key is never preceded (skipping whitespace/newlines) by
?- that position is exclusively the ternary true-branch - so a bounded backward scan for the preceding non-whitespace char rules the shape out, the same way #1221's Invocation Shield rules out bare call statements. JavaScript and TypeScript share the branch, so the gate covers both.Test plan
Measured against
language-crucible:The issue's repro now yields zero satellites; added a regression test covering both languages. Detector + TS/JS extraction suites: 255 passed. Both crucible modes pass after re-blessing the golden masters via update_golden_master.py.
Pairs with #1654 (#1631) and #1655 (#1629) - the three fixes touch the same
_slice_by_bracesregion independently and merge in any order.