Skip to content

fix(typescript): read a concise-arrow or parenthesized ternary condition as its predicate boundary (#8464) - #8476

Merged
EffortlessSteven merged 4 commits into
mainfrom
claude/project-thread-g1yvyc
Oct 17, 2026
Merged

EffortlessSteven merged 4 commits into
mainfrom
claude/project-thread-g1yvyc

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Requested by Steven · project thread

Before: export const tax = (n) => n > 100 ? a : b;, => (n > 100 ? a : b) and return (n > 100 ? a : b); read weakly_exposed even when the test called both sides of the boundary with exact toBe, because only return cond ? a : b had its condition read. The same logic as a block-body arrow or a plain function read exposed.

After: those shapes read exposed when the test hits the boundary input and stay weakly_exposed when it does not (checked on a scratch project with and without tax(100)).

Closes #8464 (the static/receiver-call rows listed there as separate shapes are not part of this PR).

How: return_ternary_condition now reads its expression from returned_expression, which accepts return … 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 check was not run locally (needs the offline cargo cache for locked fixture deps).


Generated by Claude Code

…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
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 69 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: f60bd595-9a37-4d4c-ae2b-889334d62e21
📥 Commits

Reviewing files that changed from the base of the PR and between 15fb052 and 15bd12c.

📒 Files selected for processing: 3
  • changelog.d/8464-arrow-ternary-boundary.md
  • crates/ripr/src/analysis/language/typescript/probe_shape.rs
  • crates/ripr/src/analysis/language/typescript/tests.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 async and otherwise requires the head initializer to start with ( or be a bare identifier; an async function f(...) declaration or a generator function* arrow would not reach returned_expression because leading lacks 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 as n = 10 > 1 rather than n > 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

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed findings

  • Changelog entry says 'the same expression as a parenthesized return' but the diff/parsetime path distinguishes return (cond ? a : b) (read) from return (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 exposed instead of weakly_exposed' but no test in this diff asserts exposed vs weakly_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_expression accepts it via the paren-balanced branch with no ? inside parameters, then hands the body to return_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, so own_arrow = true. Body n > 1 ? a : b proceeds to return_ternary_condition and is unwrapped to condition n > 1, but inside return_relational_comparison the leading n = would assign-then-compare shape and read no boundary. Still — returned_expression did 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 through export/keyword stripping and reach =>, triggering a false Predicate reading on the callback's body.; refuted because: Head-split requires head.contains(['(', '{', '[', ',']) to be false; declaration head before = is totals (plain) and the initializer starts with rows.map, which has no => after the substring contains a (. own_arrow on rows.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 the all(is_alphanumeric\|_\|$) parameter gate could regress when a future caller introduces an arrow whose body is a bare async expression like const 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

Copy link
Copy Markdown
Member Author

Local results on the pre-changelog head dec6f7e (15bd12c only edits the changelog entry):

  • cargo test -p ripr --lib typescript: 1166 passed, 0 failed.
  • cargo xtask verdict-corpus check-all: 4 corpora, 0 contradictions.
  • cargo xtask precommit: exit 0. goldens check was not run locally (offline cargo cache unavailable); hosted gates will run it.

Independent fresh-subagent reviews found and I fixed: destructuring/parameter-default arrows, curried arrows, (a) ? n => … initializers, quote-unaware paren strip, string-borne =>, mangled (a > b) && (c) ? x : y strip, and returned arrows read as ternaries. The final review of dec6f7e found no wrong credit, regression or panic (about 55 inputs traced). Known residual (pre-existing): return (a > 1 ? x : y) ? p : q credits the inner condition.

Static-method and instance-receiver boundary rows (#8464) are not changed here.


Generated by Claude Code

@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 17, 2026 14:21
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 : b would misparse condition as n = 10 > 1.; refuted because: returned_expression rejects any declaration head containing (, {, [, or ,, so function g(cb = x => ...) and const { fmt = (x) => ... } = opts are excluded. A bare const 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) and return (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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeScript preview: boundary witness never parses a ternary in a concise arrow body or return (cond ? a : b)

2 participants