Skip to content

Add numeric min and max builtins#3597

Draft
ATX24 wants to merge 1 commit into
canaryfrom
cursor/baml-numeric-max-min-5d8d
Draft

Add numeric min and max builtins#3597
ATX24 wants to merge 1 commit into
canaryfrom
cursor/baml-numeric-max-min-5d8d

Conversation

@ATX24

@ATX24 ATX24 commented May 29, 2026

Copy link
Copy Markdown
Contributor

Pull Request Template

Thanks for taking the time to fill out this pull request!

Issue Reference

Please link to any related issues

  • This PR fixes/closes #[issue number]

Changes

Please describe the changes proposed in this pull request

  • Add root baml.max and baml.min builtins for same-type numeric values (int/float).
  • Add TIR validation so both arguments must resolve to the same numeric type.
  • Implement VM native handling and codegen extraction/generation coverage.
  • Add focused runtime/type-check tests for int, float, mixed numeric, and non-numeric calls.

Testing

Please describe how you tested these changes

  • Unit tests added/updated
  • Manual testing performed
  • Tested in linux cloud workspace

Commands run:

  • cargo test -p baml_builtins2_codegen
  • cargo test -p baml_tests --test numeric_min_max
  • cargo test --lib (reached unrelated environment linker failures: missing Node N-API symbols in bridge_nodejs and missing libpython3.12 for bridge_python)
  • cargo test -p baml_compiler2_tir --lib
  • cargo test -p bex_vm --lib
  • cargo test -p baml_lsp2_actions --lib

Screenshots

If applicable, add screenshots to help explain your changes

N/A

PR Checklist

Please ensure you've completed these items

  • I have read and followed the contributing guidelines
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

Additional Notes

Add any other context about the PR here

The stdlib currently cannot represent true overloaded function definitions with the same bytecode name, so these are exposed as generic same-type numeric builtins with compiler-side validation to provide the intended int/float overload behavior.

Open in Web Open in Cursor 

@vercel

vercel Bot commented May 29, 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, Comment May 29, 2026 12:47am
promptfiddle Ready Ready Preview, Comment May 29, 2026 12:47am
promptfiddle2 Error Error May 29, 2026 12:47am

Request Review

@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0fccb916-b84d-4f93-8fa9-ee8371c7b7bb

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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/baml-numeric-max-min-5d8d

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 and usage tips.

@github-actions

Copy link
Copy Markdown

Binary size checks passed

7 passed

Artifact Platform Gzip Baseline Delta Status
bridge_cffi Linux 6.6 MB 6.6 MB +23.0 KB (+0.3%) OK
bridge_cffi-stripped Linux 5.7 MB 5.7 MB -26.3 KB (-0.5%) OK
bridge_cffi macOS 5.5 MB 5.1 MB +365.6 KB (+7.2%) OK
bridge_cffi-stripped macOS 4.7 MB 4.7 MB -7.5 KB (-0.2%) OK
bridge_cffi Windows 5.5 MB 5.1 MB +376.0 KB (+7.4%) OK
bridge_cffi-stripped Windows 4.8 MB 4.7 MB +109.8 KB (+2.4%) OK
bridge_wasm WASM 3.7 MB 3.8 MB -80.8 KB (-2.1%) OK

Generated by cargo size-gate · workflow run

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.

2 participants