Skip to content

fix(test): typed-feedback entry-return ordering assertion compared unrelated sites#6840

Open
TheHypnoo wants to merge 1 commit into
mainfrom
fix/typed-feedback-entry-return-ordering
Open

fix(test): typed-feedback entry-return ordering assertion compared unrelated sites#6840
TheHypnoo wants to merge 1 commit into
mainfrom
fix/typed-feedback-entry-return-ordering

Conversation

@TheHypnoo

Copy link
Copy Markdown
Member

What

typed_feedback_trace_dump_runs_before_entry_return in
crates/perry-codegen/tests/typed_feedback.rs has been red on main
(reproduced at 8b2c736, macOS arm64).

Codegen is not the problem. add_pre_return_void_call in
crates/perry-codegen/src/codegen/entry.rs:469 splices
call void @js_typed_feedback_maybe_dump_trace() in front of every ret in
main, via the return-site rewrite in crates/perry-codegen/src/function.rs:499.
It still does.

The test was measuring the wrong thing. It compared two rfinds over the whole
module text:

let dump_pos = ir.rfind("call void @js_typed_feedback_maybe_dump_trace()");
let ret_pos  = ir.rfind("ret i32 0");
assert!(dump_pos < ret_pos);

main has more than one return. The emitted IR:

event_loop.host_return.3:
  call void @js_typed_feedback_maybe_dump_trace()
  ret i32 0
…
event_loop.exit.5:
  …
  %r38 = call i32 @js_process_pending_exit_code()
  call void @js_typed_feedback_maybe_dump_trace()
  ret i32 %r38

The host-return early exit is the one that returns a literal i32 0; the
event-loop exit returns the pending exit code. So rfind("ret i32 0") landed on
the first return and rfind(dump) on the second dump — two unrelated sites. The
assertion failed while the property it names held.

Change

Slice the IR to main's body and check every return site: each ret must be
immediately preceded by the dump call. That covers both returns instead of one,
and it is the ordering the epilogue actually guarantees.

Verification

  • cargo test -p perry-codegen --test typed_feedback — 15/15 pass.
  • Negative check: deleting the add_pre_return_void_call at entry.rs:469
    fails the new test. The old shape could not guarantee that.

Integration suites under crates/*/tests/ don't run per-PR (#5960), which is why
this sat red. Sibling stale test native_proof_buffer_views is fixed in #6839;
this one is untouched there.

…related sites

typed_feedback_trace_dump_runs_before_entry_return was red on main. Codegen
is correct: add_pre_return_void_call splices the trace dump before every ret
in main. The test compared rfind of the dump call against rfind of
"ret i32 0" over the whole module. main has two returns, and the host-return
early exit is the one that returns a literal i32 0, so the two searches
landed on unrelated sites.

Slice the IR to main's body and assert every ret is immediately preceded by
the dump call. Deleting the add_pre_return_void_call in entry.rs now fails
the test.
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@TheHypnoo, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 20 minutes

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).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3eead1a1-84aa-4e29-8271-d4ea5729c8de

📥 Commits

Reviewing files that changed from the base of the PR and between 8b2c736 and bbff0e4.

📒 Files selected for processing (2)
  • changelog.d/6840-typed-feedback-entry-return-ordering.md
  • crates/perry-codegen/tests/typed_feedback.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/typed-feedback-entry-return-ordering

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@TheHypnoo TheHypnoo added the bug Confirmed defect or regression label Jul 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Confirmed defect or regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant