Repository navigation
fix(typescript): read a concise-arrow or parenthesized ternary condition as its predicate boundary (#8464) - #8476
Conversation
…renthesized ternary as its predicate boundary (#8464) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QGSS8c2jNy1Ch29DmsEkfX
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Next included review available in 43 minutes. View limit details
Comment |
There was a problem hiding this comment.
Decision
- Needs reviewer attention before upstream: findings remain.
Confirmed findings
- Changelog entry references #8464 but does not enumerate the static/receiver-call rows that the PR body explicitly excludes; readers scanning the changelog may assume broader coverage than delivered.
- The async-bare-name heuristic only strips a leading
asyncand otherwise requires the head initializer to start with(or be a bare identifier; anasync function f(...)declaration or a generatorfunction*arrow would not reachreturned_expressionbecauseleadinglacks a recognized declaration prefix, but a future user-defined async wrapper (const f = asyncWrap(...)) cannot reach the arrow branch — acceptable since no current caller depends on it.
Verification questions
- Confirm returned_expression relies on balanced-paren heuristic to distinguish a declared arrow initializer from a callback arrow nested in a call.
- Confirm default-parameter arrow body (
(n = 10) => n > 1 ? a : b) is not in tests; own_arrow returns true (paren-balanced) so condition would be parsed asn = 10 > 1rather thann > 1.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
…ation's own arrow (#8464) Reject destructuring and parameter-default arrows, curried arrows and conditional-initializer arrows; make the paren strip quote-aware. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QGSS8c2jNy1Ch29DmsEkfX
There was a problem hiding this comment.
Confirmed findings
- Changelog entry says 'the same expression as a parenthesized return' but the diff/parsetime path distinguishes
return (cond ? a : b)(read) fromreturn (cond) ? a : b(left as None). Documentation mentions the parenthesized return form only implicitly via the bullet; readers may expect symmetric handling. - changelog.d/8464-arrow-ternary-boundary.md:1 — Changlog sentence 'A test that calls both sides of the boundary reads exposed instead of weakly_exposed' is a behavior claim tied to the probe, not a general guarantee for the arrow shapes. Reword to describe the probe outcome without implying exhaustive coverage, and clarify that static/receiver-call shapes from #8464 are out of scope.
- Changelog entry says 'A test that calls both sides of the boundary reads
exposedinstead ofweakly_exposed' but no test in this diff assertsexposedvsweakly_exposed; only Predicate family and 'total == 100' discriminator are asserted. Weakness is minor because the family-classification route and prior verdict-corpus coverage (169 TS cases, 0 contradictions) per author substantiate the claim. - crates/ripr/src/analysis/language/typescript/tests.rs:5895 — The new test does not cover a default-parameter arrow body such as
export const tax = (total = 100) => total > 100 ? total * 2 : total * 3;.returned_expressionaccepts it via the paren-balanced branch with no?insideparameters, then hands the body toreturn_ternary_condition. Document the intended behavior with an explicit negative (or positive) assertion so the guard surface stays intentional.
Verification questions
- Confirm changelog claims a fixture-input drift-free transition and that no fixture contains the new shapes; Proof-by-non-claim is weaker than a receipt; request the broker run the goldens check before gate close.
- Confirm default-parameter arrow body, e.g.
(n = 10) => n > 1 ? a : b—parameters = "(n = 10)"starts with(, parens balanced, no?inside, soown_arrow = true. Bodyn > 1 ? a : bproceeds toreturn_ternary_conditionand is unwrapped to conditionn > 1, but insidereturn_relational_comparisonthe leadingn =would assign-then-compare shape and read no boundary. Still —returned_expressiondid not reject default-param arrows. - Confirm paren-unwrap guard
!inner.contains(['"','\'',''])` is the only structural check; a string template or comment marker preceding the opening paren of the ternary is impossible to hit here (return/arrow already passed the leading check), so the guard actually only protects against the trivial case of a quote in the inner text itself. - Confirm curried-arrow detection uses 'contains(" => ")' on the prefix before ' ? '; safe for the tested shape but not exhaustively proven for
=> a =>currying on the same line. Already covered by a test case; no action needed.
Refuted
- Callback arrow in a call (e.g.,
rows.map((row) => row.total > 100 ? 1 : 2)) could leak throughexport/keyword stripping and reach=>, triggering a false Predicate reading on the callback's body.; refuted because: Head-split requireshead.contains(['(', '{', '[', ','])to be false; declaration head before=istotals(plain) and the initializer starts withrows.map, which has no=>after the substring contains a(. own_arrow onrows.map((row)would either fail the balanced-paren check or never reach the split_once, so returned_expression returns None. New test asserts None for this exact line. - The async-bare-name heuristic (
strip_prefix("async ")) plus theall(is_alphanumeric\|_\|$)parameter gate could regress when a future caller introduces an arrow whose body is a bare async expression likeconst f = async x => await do(x)— no current caller relies on it, but adding the helper now bakes in the limitation.; refuted because: The PR's stated narrow target (ternary conditional reading) does not require reading async bodies; deferring async arrow support is a scope decision, not a boundary regression. Adding a future helper for async arrows is independent of this fix and trivially additive. - Changlog overclaims scope: states 'test that calls both sides of the boundary reads exposed instead of weakly_exposed' but this is the PR's claimed behavior, not a documented invariant for the broader fix surface.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
…returned arrows in ternary capture (#8464) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QGSS8c2jNy1Ch29DmsEkfX
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QGSS8c2jNy1Ch29DmsEkfX
|
Local results on the pre-changelog head dec6f7e (15bd12c only edits the changelog entry):
Independent fresh-subagent reviews found and I fixed: destructuring/parameter-default arrows, curried arrows, Static-method and instance-receiver boundary rows (#8464) are not changed here. Generated by Claude Code |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
Decision
- Needs reviewer attention before upstream: findings remain.
Confirmed findings
- Changelog claims symmetric 'return (cond ? a : b)' handling but probe now only strips the wrapping paren around the whole conditional; balanced '(a > b) ? x : y' still returns None (covered by test). Documentation phrasing acceptable but not strictly symmetric.
- Helper layering is clean: wrapper_paren_inner, parameters_close_before_annotation, returned_expression, return_ternary_condition form a small DAG with no duplication; changelog scope aligns with diff scope. No architectural regression in boundary placement.
Verification questions
- Confirm new test asserts Predicate family and 'total == 100' discriminator for 4 arrow/paren shapes and None for 12 non-boundary shapes; no direct exposed vs weakly_exposed assertion.
- Confirm regression coverage does not include a unit test that fixes a 'weakly_exposed' baseline for a sibling shape and flips to 'exposed' after the diff, so the red→green claim is not directly witnessed inside this file; dependence on external verdict-corpus is acceptable but should be noted in the changelog.
Refuted
- Default-parameter arrow body like
(n = 10) => n > 1 ? a : bwould misparse condition asn = 10 > 1.; refuted because:returned_expressionrejects any declaration head containing(,{,[, or,, sofunction g(cb = x => ...)andconst { fmt = (x) => ... } = optsare excluded. A bareconst f = (n = 10) => ...is excluded by the head '(' check; path is fail-closed via returned_expression returning None, and NoInversion cover via two negative assertions in the new test.
Parked follow-ups
- Changelog sentence claims both
=> (n > 100 ? a : b)andreturn (n > 100 ? a : b);are now read; the new positive test does not include the bare-=> (cond ? a : b)shape and only includes the parenthesized-body and parenthesized-return variants as positives. The bare paren-wrapped arrow body is otherwise exercised by the in-PR verbatim line=> total > 100 ? total * 2 : total * 3;minus the leading paren, so the documented=> (cond ? a : b)literal is not pinned by a test.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
Requested by Steven · project thread
Before:
export const tax = (n) => n > 100 ? a : b;,=> (n > 100 ? a : b)andreturn (n > 100 ? a : b);readweakly_exposedeven when the test called both sides of the boundary with exacttoBe, because onlyreturn cond ? a : bhad its condition read. The same logic as a block-body arrow or a plain function readexposed.After: those shapes read
exposedwhen the test hits the boundary input and stayweakly_exposedwhen it does not (checked on a scratch project with and withouttax(100)).Closes #8464 (the static/receiver-call rows listed there as separate shapes are not part of this PR).
How:
return_ternary_conditionnow reads its expression fromreturned_expression, which acceptsreturn …or the body of a declared concise arrow (export/const/let/var … = (params) => body); the arrow must be the declaration's own initializer, so a callback in a call (rows.map((row) => …)) and a block body stay unread. A(that wraps the whole conditional is dropped from the condition; a balanced(a > b) ? …is left as before.Verified locally:
cargo xtask precommit(exit 0),cargo test -p ripr --lib typescript(1166 passed),cargo xtask verdict-corpus check-all(TypeScript 169 cases, 0 contradictions). No fixture input contains these shapes, so no golden drift is expected;cargo xtask goldens checkwas not run locally (needs the offline cargo cache for locked fixture deps).Generated by Claude Code