Skip to content

fix(mir): dispatch optional interface method calls - #4435

Merged
codeshaunted merged 2 commits into
canaryfrom
codex/b-1180
Aug 14, 2026
Merged

fix(mir): dispatch optional interface method calls#4435
codeshaunted merged 2 commits into
canaryfrom
codex/b-1180

Conversation

@codeshaunted

@codeshaunted codeshaunted commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Issue Reference

Fixes B-1180.

Changes

  • Narrow optional receivers to their non-null type before selecting interface dispatch.
  • Preserve instantiated generic interface arguments during dispatch.
  • Add native BAML regressions for null, non-null, and generic receivers.

Testing

  • baml check --project crates/baml_tests/baml_src
  • BAML regressions: 2 passed
  • cargo test -p baml_compiler2_mir: 3 passed
  • cargo test -p baml_tests --lib compiler2_mir: 27 passed
  • cargo clippy -p baml_compiler2_mir --all-targets -- -D warnings
  • Repository pre-commit hooks

Summary by CodeRabbit

  • Bug Fixes

    • Fixed optional interface method calls so dispatch works correctly when values are present or null.
    • Preserved fallback behavior for optional method access.
  • Tests

    • Added coverage for optional named-method and generic getter dispatch.
    • Verified correct results for both populated and null values.

@linear

linear Bot commented Aug 14, 2026

Copy link
Copy Markdown

B-1180

@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
beps Ready Ready Preview Aug 14, 2026 11:19pm
promptfiddle2 Ready Ready Preview Aug 14, 2026 11:19pm

Request Review

@github-actions

Copy link
Copy Markdown

⏭️ Performance benchmarks were skipped

Perf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to canary/main.

To run them on this PR, do any of the following, then push a commit (or re-run CI):

  • Add RUN_CODSPEED=1 to the PR description, or
  • Include run-perf or /perf in the PR title or any commit message.

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (2)
  • baml_language/crates/baml_tests/snapshots/baml_src/_root.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/interfaces.snap is excluded by !**/*.snap

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5f64d477-6521-483d-a15a-cbbd35a76227

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 172942d4-d3b0-45ad-ad14-66ec9e932468

📥 Commits

Reviewing files that changed from the base of the PR and between 8ee3815 and 1a176b2.

📒 Files selected for processing (2)
  • baml_language/crates/baml_compiler2_mir/src/lower.rs
  • baml_language/crates/baml_tests/baml_src/ns_interfaces/b_1180.baml

📝 Walkthrough

Walkthrough

The MIR lowering now resolves interface dispatch targets for optional member accesses by removing null from the base type. Tests cover named and generic optional method dispatch for present and null values.

Changes

Optional interface dispatch

Layer / File(s) Summary
Resolve optional member dispatch targets
baml_language/crates/baml_compiler2_mir/src/lower.rs
The new helper narrows optional base types before resolving interface or concrete dispatch targets. Existing expression-based fallback resolution remains available.
Validate named and generic optional dispatch
baml_language/crates/baml_tests/baml_src/ns_interfaces/b_1180.baml
Tests cover named interface methods and generic getter methods for present and null optional values.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 1a176

This localized compiler dispatch fix includes regression and package tests, with only routine pre-merge test confirmation remaining. No actionable merge-blocking risk remains.

Possibly related PRs

Suggested reviewers: 2kai2kai2, aaronvg, antoniosarosi

Poem

I hop through optional paths with care,
Strip null before dispatching there.
Named calls land, generic calls too,
Nulls return their fallback value true.
A tidy MIR trail, from rabbit to you.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the MIR fix for optional interface method dispatch.
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 codex/b-1180

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.

@vercel
vercel Bot temporarily deployed to Preview – beps August 14, 2026 23:03 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 August 14, 2026 23:10 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps August 14, 2026 23:13 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 August 14, 2026 23:19 Inactive
@codeshaunted
codeshaunted enabled auto-merge August 14, 2026 23:19
@codeshaunted
codeshaunted added this pull request to the merge queue Aug 14, 2026
@github-actions

Copy link
Copy Markdown

Binary size checks passed

7 passed

Artifact Platform File Gzip Gated on Baseline Delta Status
baml-cli Linux 🔒 26.5 MB 11.2 MB file 27.4 MB -915.5 KB (-3.3%) OK
packed-program Linux 🔒 17.2 MB 6.9 MB file 18.6 MB -1.4 MB (-7.4%) OK
baml-cli macOS 🔒 20.6 MB 9.8 MB file 21.3 MB -698.0 KB (-3.3%) OK
packed-program macOS 🔒 13.5 MB 6.1 MB file 14.5 MB -950.1 KB (-6.6%) OK
baml-cli Windows 🔒 22.2 MB 10.0 MB file 23.0 MB -783.5 KB (-3.4%) OK
packed-program Windows 🔒 14.4 MB 6.2 MB file 15.5 MB -1.1 MB (-7.4%) OK
bridge_wasm WASM 15.8 MB 🔒 4.2 MB gzip 4.6 MB -406.7 KB (-8.8%) OK

🔒 = the size this artifact is GATED on (ceiling + delta). Binaries gate on file size (installed binary); WASM gates on gzip (download size). The other size is shown for information only.


Generated by cargo size-gate · workflow run

Merged via the queue into canary with commit c0153b2 Aug 14, 2026
82 checks passed
@codeshaunted
codeshaunted deleted the codex/b-1180 branch August 14, 2026 23:32
meefs pushed a commit to meefs/baml that referenced this pull request Aug 15, 2026
## Summary

- add comprehensive release notes for the independent `baml_language`
0.17.0 release line
- separate user-facing features, breaking and compatibility changes,
fixes, performance work, and internal changes
- synchronize the canary version, SDK packages, bridge runtime
identities, generated Node loader guards, and VS Code extension to
`0.17.0`

## Verified comparison range

- previous release: `baml-language-0.16.0` at
`2e021b3429db8769656e9b8646657c1863789169`
- reviewed product target:
`baml-language-source-c0153b20108bc428b77a53128b9a59ddeb4e2b42` at
`c0153b20108bc428b77a53128b9a59ddeb4e2b42`
- the reviewed product target was also `origin/canary` when the updated
notes were prepared
- full product comparison:
BoundaryML/baml@baml-language-0.16.0...baml-language-source-c0153b20108bc428b77a53128b9a59ddeb4e2b42

The product range contains 43 monorepo commits. The notes cover every
merged PR in the range that touched `baml_language/`, plus the
baml_language-specific macOS test suppression and binary-size baseline
workflow update. The post-BoundaryML#4424 review added BoundaryML#4427, BoundaryML#4431, BoundaryML#4432, BoundaryML#4433,
BoundaryML#4434, BoundaryML#4103, and BoundaryML#4435. BoundaryML#3975 and BoundaryML#3510 are in the monorepo comparison
but are excluded because they change only the main engine/docs release
line. Other unrelated documentation, website, JetBrains, on-call, and
general monorepo changes are also excluded. The five commits in this PR
add and refine the changelog and mechanically prepare release metadata;
they do not add product behavior beyond the reviewed target.

## Release safety

This PR remains draft. Its `baml_language/release.toml` change is the
documented canary release request: merging it to `canary` after green CI
would dispatch the production 0.17.0 release workflow. Do not merge or
mark ready until Sam explicitly approves the release.

No package was published, no release tag was created or pushed, no
artifact was uploaded, and no production release workflow was triggered
during preparation.

## Validation

- `scripts/baml-language-version sync`
- `scripts/baml-language-version check`
- `scripts/baml-language-version show` → `0.17.0`
- `scripts/baml-language-version compute --channel canary` → `0.17.0`
- `python3 -m unittest scripts.tests.test_baml_language_version
scripts.tests.test_release_pipeline_contract` — 39 passed
- `cargo test --manifest-path baml_language/Cargo.toml -p baml_version`
- `mise run validate-markdown` from `baml_language/`
- changed-file `prek` hooks, including Cargo formatting, Clippy, C++
formatting, TOML checks, and Markdown validation
- `git diff --check`


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added system and filesystem capabilities, cryptography utilities, time
arithmetic, assertions, bitwise operations, improved indexing, toolchain
pinning, and LSP code actions.
  - Added stable merge sorting for array helpers.

- **Bug Fixes**
- Improved language behavior, diagnostics, CLI evaluation, playground
workflows, and language-server synchronization.

- **Breaking Changes**
- Updated string APIs, function field requirements, prompt syntax, and
type-checking behavior.

- **Documentation**
  - Added release notes for version 0.17.0.

- **Release**
  - Published version 0.17.0 across supported SDKs and tooling.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant