Fix compiler edge-case regressions - #4140
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
⏭️ Performance benchmarks were skippedPerf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to To run them on this PR, do any of the following, then push a commit (or re-run CI):
|
📝 WalkthroughWalkthroughThe changes update MIR handling for non-recursive aliases and nested projection assignments, refine parser detection of expression-bodied calls using ChangesMIR lowering corrections
Function body detection
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@baml_language/crates/bex_vm/tests/projection_dest_calls.rs`:
- Around line 105-128: Update
method_call_result_can_be_the_base_of_nested_field_assignment so the require
call has an observable side effect or returns distinguishable results, then
assert the call occurs exactly once while preserving the nested assignment
behavior. Use the existing SRC program and run_bool assertion, adding only the
minimal counter/state and expected-value checks needed to detect duplicate
evaluation.
🪄 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: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d1788e9e-bfad-42c2-8753-7975f9b45277
📒 Files selected for processing (4)
baml_language/crates/baml_compiler2_mir/src/lower.rsbaml_language/crates/baml_compiler_parser/src/parser.rsbaml_language/crates/baml_tests/tests/interface_type_alias_iteration.rsbaml_language/crates/bex_vm/tests/projection_dest_calls.rs
|
|
||
| // The base of a projection is itself allowed to be a call expression. MIR must | ||
| // evaluate that call into a local before appending field projections. | ||
| #[test] | ||
| fn method_call_result_can_be_the_base_of_nested_field_assignment() { | ||
| const SRC: &str = r#" | ||
| class Info { title: string? } | ||
| class Record { info: Info } | ||
| class Store { | ||
| record: Record | ||
| function require(self) -> Record { self.record } | ||
| } | ||
|
|
||
| function main() -> bool { | ||
| let store = Store { | ||
| record: Record { info: Info { title: null } }, | ||
| }; | ||
| store.require().info.title = "triage"; | ||
| store.record.info.title == "triage" | ||
| } | ||
| "#; | ||
|
|
||
| assert!(run_bool(SRC, "user.main")); | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Make the regression assert exactly-once evaluation.
require is pure and always returns self.record, so this test also passes if lowering invokes it twice. Add an observable call count or distinct result and assert that the base expression is evaluated exactly once.
🤖 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 `@baml_language/crates/bex_vm/tests/projection_dest_calls.rs` around lines 105
- 128, Update method_call_result_can_be_the_base_of_nested_field_assignment so
the require call has an observable side effect or returns distinguishable
results, then assert the call occurs exactly once while preserving the nested
assignment behavior. Use the existing SRC program and run_bool assertion, adding
only the minimal counter/state and expected-value checks needed to detect
duplicate evaluation.
Binary size checks passed✅ 7 passed
Generated by |
## Summary - make the nested projection assignment regression track calls to `Store.require()` - assert the assignment still mutates the expected nested field - assert the projection base is evaluated exactly once ## Why This is a test-only follow-up to the unresolved review on BoundaryML#4140. The original regression used a pure `require()` method, so it could not detect duplicate evaluation of the projection base. ## Impact No production behavior changes. The strengthened regression now guards both correct nested assignment and exactly-once evaluation. ## Validation - `cargo nextest run -p bex_vm --test projection_dest_calls method_call_result_can_be_the_base_of_nested_field_assignment` - `cargo nextest run -p bex_vm --test projection_dest_calls` - `cargo fmt --all --check` - `git diff --check` <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Only updates an integration test; no compiler, MIR, or runtime behavior changes. > > **Overview** > **Test-only** change to `method_call_result_can_be_the_base_of_nested_field_assignment` in `projection_dest_calls.rs`. > > The nested assignment `store.require().info.title = "triage"` still must mutate the right field; the test now also proves the projection base is evaluated **exactly once**. `Store` gains a `calls` counter incremented inside `require()`, and `main` asserts `store.calls == 1` in addition to the title check. A pure `require()` that only returned `self.record` could pass even if MIR evaluated the call twice. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 7f02714. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
Summary
client =andprompt =call arguments as ordinary arguments instead of LLM function bodiesWhy
These independent compiler edge cases surfaced while migrating the BEPv2 scenarios. Each bug now has focused regression coverage.
Validation
cargo fmt --all --checkgit diff --check origin/canary..HEADNote
Medium Risk
Touches MIR lvalue lowering, type-alias interface resolution, and function-body disambiguation; behavior changes are narrow but affect core compile paths.
Overview
Three independent compiler edge-case fixes, each with focused regression tests.
MIR lowering now evaluates the base expression of a projection assignment (e.g.
store.require().info.title = ...) into a temp before building the lvalue, so call results can serve as nested assignment bases.Interface iteration resolves non-recursive type aliases when looking up interface views (e.g.
foroverlive.events()when the return type istype EventStream = Event[]), so iterable lowering works through transparent aliases.Parser no longer treats
client/promptat the start of a function body as LLM directives when the next token is=,,, or), so bodies likeAsk("hi", client = ...)parse as expression bodies instead of LLM bodies.Reviewed by Cursor Bugbot for commit 90f66d4. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
Bug Fixes
clientorpromptnamed arguments.Tests