Skip to content

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

Merged
proggeramlug merged 4 commits into
mainfrom
fix/typed-feedback-entry-return-ordering
Jul 30, 2026
Merged

fix(test): typed-feedback entry-return ordering assertion compared unrelated sites#6840
proggeramlug merged 4 commits into
mainfrom
fix/typed-feedback-entry-return-ordering

Conversation

@TheHypnoo

@TheHypnoo TheHypnoo commented Jul 25, 2026

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.

Summary by CodeRabbit

  • Tests

    • Improved coverage to verify that typed-feedback trace dumps occur before every application entry-point return.
    • Updated validation to focus specifically on the entry-point function and detect ordering issues more reliably.
  • Documentation

    • Added a changelog entry describing the corrected test coverage and trace-dump ordering validation.

…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

Review Change Stack

Warning

Review limit reached

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

Next review available in: 57 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: e778a0af-611e-4045-a15d-f5af42ba3ec4

📥 Commits

Reviewing files that changed from the base of the PR and between 396a485 and 55f21fc.

📒 Files selected for processing (2)
  • changelog.d/6840-typed-feedback-entry-return-ordering.md
  • crates/perry-codegen/src/loop_purity.rs
📝 Walkthrough

Walkthrough

The test now extracts main from compiled IR and verifies that js_typed_feedback_maybe_dump_trace() immediately precedes every return instruction. The changelog documents the corrected validation strategy and existing codegen behavior.

Changes

Typed feedback validation

Layer / File(s) Summary
Main return ordering validation
crates/perry-codegen/tests/typed_feedback.rs, changelog.d/6840-typed-feedback-entry-return-ordering.md
The test isolates main, checks every return site for the preceding trace-dump call, and documents the corrected assertion strategy.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: proggeramlug, andrewtdiz

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main fix to the typed-feedback test assertion.
Description check ✅ Passed It covers the summary, concrete changes, and verification, though it omits the template's Related issue and checklist sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 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
# Conflicts:
#	crates/perry-codegen/tests/typed_feedback.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
crates/perry-codegen/tests/typed_feedback.rs (1)

222-245: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Keep this regression check in a PR-visible unit-test path.

This remains an integration test under crates/*/tests/*.rs. Per repository guidance, add equivalent acceptance coverage in a cargo test-visible unit-test module so the regression is exercised by default.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/perry-codegen/tests/typed_feedback.rs` around lines 222 - 245, Move or
duplicate this typed-feedback return-order regression check into a cargo
test-visible unit-test module, while preserving coverage of every return in main
via entry_fn_body and the existing assertions. Keep the integration test only if
needed, but ensure the equivalent check runs by default through the repository’s
unit-test path.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@changelog.d/6840-typed-feedback-entry-return-ordering.md`:
- Around line 19-20: Update the CI explanation in the changelog entry to remove
the stale claim that crates/*/tests/ integration suites do not run per PR;
describe that changed suites are now selected by the PR e2e-scoped job, or
clearly frame the omission as historical context.

---

Nitpick comments:
In `@crates/perry-codegen/tests/typed_feedback.rs`:
- Around line 222-245: Move or duplicate this typed-feedback return-order
regression check into a cargo test-visible unit-test module, while preserving
coverage of every return in main via entry_fn_body and the existing assertions.
Keep the integration test only if needed, but ensure the equivalent check runs
by default through the repository’s unit-test path.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 39fc0c21-12ba-4ca1-b27e-d1f7d85cfbcc

📥 Commits

Reviewing files that changed from the base of the PR and between 82486d6 and 396a485.

📒 Files selected for processing (2)
  • changelog.d/6840-typed-feedback-entry-return-ordering.md
  • crates/perry-codegen/tests/typed_feedback.rs

Comment thread changelog.d/6840-typed-feedback-entry-return-ordering.md Outdated
@proggeramlug
proggeramlug merged commit 17c0ff9 into main Jul 30, 2026
28 of 33 checks passed
@proggeramlug
proggeramlug deleted the fix/typed-feedback-entry-return-ordering branch July 30, 2026 02:25
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.

2 participants