Skip to content

Resolve dot-qualified builtin class methods in baml describe#3695

Draft
ATX24 wants to merge 2 commits into
canaryfrom
cursor/baml-describe-instance-methods-98d8
Draft

Resolve dot-qualified builtin class methods in baml describe#3695
ATX24 wants to merge 2 commits into
canaryfrom
cursor/baml-describe-instance-methods-98d8

Conversation

@ATX24

@ATX24 ATX24 commented Jun 4, 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

The error

Given a minimal project:

function dummy(x: int) -> int { x }

Before this change, the natural method lookup failed:

$ baml describe Array.reduce
No symbol found: Array.reduce

The command exited with code 4 even though reduce is a builtin instance method on Array.

Root cause

baml_language/crates/baml_cli/src/describe_command.rs::dispatch handled explicit builtin package paths (baml.Array.reduce), lowercase primitive aliases (string.length), keywords, root.*, and user-package structural paths. For an unqualified builtin class member like Array.reduce, user-package resolution returned None, then the CLI fell back to substring describe with the whole string Array.reduce as an opaque symbol name. That fallback never reaches describe_item_member, so it printed No symbol found.

Once Array.reduce resolved, baml_language/crates/baml_lsp2_actions/src/describe.rs::render_method_signature also needed to include method-level generic parameters from Function::generic_params; otherwise generic builtin methods documented their callback types without the <A, E> surface.

The fix

  • Added a narrowly scoped builtin class-member resolver in describe_command::dispatch after user-package resolution fails. It recognizes Class.method, searches non-user packages for a unique builtin class with that short name, and returns ResolvedTarget::Member so the existing class-method renderer is used.
  • Preserved user-project precedence: a user Class.method structural target still resolves before builtin fallback.
  • Updated method signature rendering to include method generic parameters and generic bounds.
  • Added focused CLI dispatch tests for Array.reduce and String.split without the baml. package prefix.

Verification

Same reproduction after the change:

$ cargo run -p baml_cli -- describe Array.reduce --from /tmp
warning: using the internal BAML toolchain binary directly is not recommended. Use `baml` instead.
method reduce  <builtin>/baml/containers.baml:224-226

function reduce<A, E>(self, reducer: (A, T) -> A throws E, initial: A) -> A throws E

container:
  class            Array                            <builtin>/baml/containers.baml:2

references (0):

Commands run:

$ cargo test -p baml_cli without_package_prefix
running 2 tests
...
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 183 filtered out; finished in 0.26s
$ cargo test -p baml_cli --lib && cargo test -p baml_lsp2_actions --lib
# baml_cli
test result: ok. 185 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
# baml_lsp2_actions
test result: ok. 114 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
$ LD_LIBRARY_PATH=/home/ubuntu/.local/share/mise/installs/python/3.13.13/lib:${LD_LIBRARY_PATH:-} \
  cargo test --workspace --lib --exclude bridge_nodejs
...
test result: ok

I also attempted unexcluded cargo test --lib; it is blocked in this environment by bridge_nodejs test-linking against Node N-API symbols while the installed mise Node reports node_shared=false and provides no libnode.so.

Testing

Please describe how you tested these changes

  • Unit tests added/updated
  • Manual testing performed
  • Tested in Linux Cursor Cloud environment

Screenshots

If applicable, add screenshots to help explain your changes

Not applicable.

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 where applicable
  • My changes generate no new warnings

Additional Notes

Add any other context about the PR here

The setup required pnpm install, pnpm --filter @boundaryml/baml-core-node build:debug, and CI=1 ./setup.sh under baml_language/sdk_tests/crates/typescript_node so the TypeScript SDK harness fixtures had their generated node_modules trees.

Open in Web Open in Cursor 

@vercel

vercel Bot commented Jun 4, 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 Jun 4, 2026 6:54pm
promptfiddle Ready Ready Preview, Comment Jun 4, 2026 6:54pm
promptfiddle2 Ready Ready Preview, Comment Jun 4, 2026 6:54pm

Request Review

@coderabbitai

coderabbitai Bot commented Jun 4, 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: 53906aa1-d6a5-47be-834c-23b105b85454

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-describe-instance-methods-98d8

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

github-actions Bot commented Jun 4, 2026

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.

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

Binary size checks passed

7 passed

Artifact Platform File Gzip Gated on Baseline Delta Status
baml-cli Linux 🔒 17.8 MB 7.6 MB file 24.1 MB -6.3 MB (-26.2%) OK
packed-program Linux 🔒 12.9 MB 5.5 MB file 15.1 MB -2.2 MB (-14.6%) OK
baml-cli macOS 🔒 13.6 MB 6.6 MB file 18.2 MB -4.6 MB (-25.4%) OK
packed-program macOS 🔒 9.8 MB 4.8 MB file 11.5 MB -1.7 MB (-14.4%) OK
baml-cli Windows 🔒 14.6 MB 6.7 MB file 19.6 MB -5.0 MB (-25.5%) OK
packed-program Windows 🔒 10.4 MB 4.8 MB file 12.2 MB -1.8 MB (-15.0%) OK
bridge_wasm WASM 11.9 MB 🔒 3.4 MB gzip 3.9 MB -504.5 KB (-13.0%) 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

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