Repository navigation
fix(typescript): read a toMatchObject const argument bound in the test body (RIPR-SPEC-0250) - #8134
Conversation
…t body (RIPR-SPEC-0250)
`toMatchObject(expected)` now reads the flat object literal of a
test-body `const expected = {...}` that the body names only in its
binding and that one argument, so the field pin credits the listed
returned field. Any other mention, a `let` binding, a binding outside the
test body, nested or spread literals, and bodies with `eval`, `with` or a
`\u` escape keep the weak reading.
Spec 0250 example 5 is amended; corpus row
jest-spec0250-ex05-non-literal-expected moves from gap to credited and no
other row moves. Also mirrors the instance-class wrapped-member and
nested-wrap call shapes in the match-object identity test.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013ajVbPgh9yZDQgaAHkZE8V
A read const argument no longer also reports typescript_dynamic_assertion_unresolved. Adds call-in-block and resolves-chain refusal cases, states the direct-statement, top-level and declared-before-call conditions in spec 0250, and records the ex04/ex05 row moves under Required Evidence. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013ajVbPgh9yZDQgaAHkZE8V
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Review of record — head c267343 Two independent reviewer agents read the exact candidate, each from a different angle. 1. Correctness / false-credit (adversarial). No hole introduced by this change. The reviewer checked each of these and refuted every one:
It also found one older hole that this PR does not cause: a 2. Tests / spec / contract. Nothing blocking. It raised five optional findings, all fixed in c267343:
Mutation checks:
Evidence:
Disposition: nothing blocking. Marking Ready. 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! |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
Summary by CodeRabbit
WalkthroughThe TypeScript analyzer now recognizes qualifying test-body ChangesTypeScript Match Object Field Pinning
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant TestCallback
participant AssertionCollector
participant ObjectConstantGuard
participant TypeScriptAssertion
participant FieldPinAnalysis
TestCallback->>AssertionCollector: collect assertions and test-body constants
AssertionCollector->>ObjectConstantGuard: resolve direct toMatchObject identifier
ObjectConstantGuard->>TypeScriptAssertion: attach expected_object_const
TypeScriptAssertion->>FieldPinAnalysis: provide resolved object text
Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
Decision
- Needs one verification check before upstream.
Verification questions
- Confirm diff also breaks one prior weakly_exposed reading for spec example 5; corpus row re-bless and one stat move (weakly_exposed → exposed). Reviewer should confirm the single-row move is intentional and that no other verdict row changed.
Refuted
- The 'declared_end <= call.span.start' TDZ guard is untestable and could bit-rot; an OOO call like const expected={...}; if (foo(expected)) expect(x).toMatchObject(expected); might falsely credit because the const is reachable via a hoisted binding.; refuted because: only matches[2] of (ExactValue,Strong) is asserted. False-premise: TDZ in JS throws before the assertion; no passing test can reach out-of-order use. PR body acknowledges this as one untested defensive branch.
- A 'toMatchObject(expected)' argument whose const literal has a getter or computed key could be mis-credited as flat-keyed and trip the field-pin 'lists_key' check via safe_mock_expected_object rejection path.; refuted because: safe_mock_expected_object (existing helper) rejects getters/methods/computed keys/spreads; the test 'spread' refusal case covers spread; the helper is unchanged and pre-existing. Refuted.
Parked follow-ups
- declare check (declared_end <= call.span.start) has no passing test reaching the misuse path; reaching it would be a TDZ ReferenceError at runtime, so defense is sufficient.
- Pre-existing ci/precommit script gap (npx --no-install highlight or similar) from #8134 review thread is unrelated to red/green; tests pass as-is.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
Summary
const grown = { name: "bo", adult: true }; expect(buildProfile("bo", 18)).toMatchObject(grown);readweakly_exposed, a false gap. The test pinsadultexactly as the inline-literal form does.toMatchObject(<name>)reads the flat literal of a test-bodyconstthat the body names only in its binding and that argument, so the RIPR-SPEC-0250 field pin credits it (exposed,exact_value/ strong).letbinding;.not,.resolvesor.rejectschains;eval,withor a\uescape.match_object_guard.rsgainsmatch_object_consts/match_object_const_argument.oracle.rsattaches the literal to the assertion asexpected_object_const, andts_match_object_factsreads it like an inline literal. A read argument no longer also liststypescript_dynamic_assertion_unresolved.wrapped-memberandnested-wrapcall shapes in the match-object identity test (an optional finding on fix(typescript): read a pin through a test-local identity helper (RIPR-SPEC-0249, RIPR-SPEC-0250) #8092).Swarm / Source Boundary
ripr-swarmSource-of-truth Links
Proposal: n/a
Spec: RIPR-SPEC-0250 (example 5 amended 2026-10-15)
ADR: n/a
Plan item: n/a
Governing issue or accepted claim: #6654
Acceptance delta (one sentence): corpus row
jest-spec0250-ex05-non-literal-expectedmoves gap → credited, and no other row moves.Candidate Relationships
Candidate branch:
claude/project-thread-pwvs2kStack parent or prerequisite PR: #8092 (merged)
Proposed replacement of PR: none
Scope
Scope Classification
Production delta:
toMatchObject(<const>)on a directexpect(...)statement reads the bound flat literal.Evidence/support delta:
Single acceptance criterion:
exposed, and every refusal listed above stays notexposed.Non-goals:
await expect(...). These are missed credits, not false credits.Support-tier Impact
Claim/proof notes:
Policy Impact
Proof
Results:
exposedstays at 0.AssertionContext::nested()failscall-in-block. Removing theexpected_object_const.is_none()guard instatic_limit.rsfails the positive test's limitation assertion.declared_end <= call.span.startcheck. Use before the declaration would throw a TDZ error at runtime, so no passing test can reach it.Claim Boundary
May claim: a test-body
constflat-literaltoMatchObjectargument is read when the body names it nowhere else.Must not claim: any data-flow reading of expected objects beyond that.
Rollback
Revert the squash commit and re-bless the TypeScript corpus.
Spec-Test-Code Traceability
match_object_tests.rs::match_object_pin_reads_a_test_body_object_constmatch_object_guard.rs,oracle.rs,static_limit.rs,types.rsfixtures/typescript-verdict-corpus(one row)typescript_match_object_pin_mismatchStatic Language Check
killed,survived,untested,proven, andadequate.CI Economics
n/a
Engineering Check
panic,unwrap,expect,todo, orunimplementedin production code.panic,unwrap,expect,todo, orunimplementedin tests.Gates
cargo fmt --check(via precommit)Found in review and filed separately: #8133 (an older
__proto__:key hole in the match-object pin).🤖 Generated with Claude Code
https://claude.ai/code/session_013ajVbPgh9yZDQgaAHkZE8V
Generated by Claude Code