Skip to content

Add inferred throws inlay hints - #4595

Open
codeshaunted wants to merge 1 commit into
canaryfrom
codex/throws-inlay-hints
Open

Add inferred throws inlay hints#4595
codeshaunted wants to merge 1 commit into
canaryfrom
codex/throws-inlay-hints

Conversation

@codeshaunted

@codeshaunted codeshaunted commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Changes

  • Show declaration-site inlay hints for inferred non-never throws clauses.
  • Reuse callable_throws and source-aware type rendering, with no compiler changes.
  • Suppress hints for explicit throws clauses and synthetic functions.

Testing

  • Unit tests added/updated
  • cargo test -p baml_ide -p baml_lsp
  • cargo clippy -p baml_ide -p baml_lsp --all-targets -- -D warnings
  • RUSTDOCFLAGS='-D warnings' cargo doc -p baml_ide -p baml_lsp --no-deps

Screenshots

Not applicable.

PR Checklist

  • Code follows the project style.
  • Self-review completed.
  • Documentation updated.
  • No new warnings.

Summary by CodeRabbit

  • New Features

    • Added inlay hints showing inferred throws clauses for functions that may raise user-defined errors.
    • Hints appear after return types and are omitted when a function already declares throws or cannot throw.
  • Tests

    • Added coverage for direct and propagated throws hints.
    • Added end-to-end validation of hint content, type, and position.

@vercel

vercel Bot commented Aug 25, 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 25, 2026 10:55pm
promptfiddle2 Ready Ready Preview Aug 25, 2026 10:55pm

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 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

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: 540a6db4-f30b-4303-a28b-93a7105305a4

📥 Commits

Reviewing files that changed from the base of the PR and between 3e669ec and d8a2cce.

📒 Files selected for processing (3)
  • baml_language/crates/baml_ide/src/annotations.rs
  • baml_language/crates/baml_lsp/src/dispatch/requests.rs
  • baml_language/crates/baml_lsp/tests/protocol.rs

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The IDE now emits inferred throws annotations for eligible user-defined functions. The LSP classifies these annotations as type inlay hints. IDE and protocol tests verify direct, propagated, explicit, non-throwing, suppressed, and positional cases.

Changes

Inferred throws hints

Layer / File(s) Summary
IDE throws annotation generation
baml_language/crates/baml_ide/src/annotations.rs
Adds AnnotationKind::Throws, documents its placement, emits inferred throws annotations for eligible user-defined functions, and tests direct and propagated throws behavior.
LSP hint mapping and protocol coverage
baml_language/crates/baml_lsp/src/dispatch/requests.rs, baml_language/crates/baml_lsp/tests/protocol.rs
Classifies throws annotations as type inlay hints and verifies the label, hint kind, and source position.

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

Merge Risk: ⚪ Minimal · up to d8a2c

This change adds declaration-site hints for inferred non-never throws clauses while suppressing explicit and synthetic cases; no actionable merge-blocking risk remains after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant UserDefinedFunction
  participant AnnotationBuilder
  participant LSPDispatcher
  participant LSPClient
  UserDefinedFunction->>AnnotationBuilder: provide inferred throws contract
  AnnotationBuilder->>LSPDispatcher: emit Throws annotation
  LSPDispatcher->>LSPClient: return TYPE inlay hint
Loading

Suggested reviewers: 2kai2kai2

Poem

A rabbit spots a throws sign bright
The IDE places it just right
The LSP carries the hint
Tests check each offset and print
Burrows now parse errors in sight

🚥 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 main change: adding inferred throws inlay hints.
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 3 files.
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/throws-inlay-hints

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.

@github-actions

Copy link
Copy Markdown

Binary size checks failed

2 violations · ✅ 5 passed

⚠️ Please fix the size gate issues or acknowledge them by updating baselines.

Artifact Platform File Gzip Gated on Baseline Delta Status
baml-cli Linux 🔒 72.7 MB 27.4 MB file 82.3 MB -9.6 MB (-11.7%) OK
packed-program Linux 🔒 28.5 MB 10.8 MB file 32.5 MB -4.0 MB (-12.3%) OK
baml-cli macOS 🔒 63.1 MB 25.0 MB file 63.1 MB -4.9 KB (-0.0%) OK
packed-program macOS 🔒 25.7 MB 10.1 MB file 25.8 MB -142.9 KB (-0.6%) OK
baml-cli Windows 🔒 82.8 MB 27.8 MB file 80.2 MB +2.6 MB (+3.3%) FAIL
packed-program Windows 🔒 30.7 MB 10.7 MB file 28.4 MB +2.3 MB (+8.1%) FAIL
bridge_wasm WASM 22.1 MB 🔒 5.6 MB gzip 5.7 MB -48.1 KB (-0.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.

Details & how to fix

Violations:

  • baml-cli (Windows) file_bytes: 82.8 MB exceeds limit of 82.6 MB (exceeded by +204.6 KB, policy: max_file_bytes)
  • baml-cli (Windows) file_delta_pct: +3.3% exceeds limit of 3.0% (exceeded by +0.3pp, policy: max_delta_pct)
  • packed-program (Windows) file_bytes: 30.7 MB exceeds limit of 29.3 MB (exceeded by +1.5 MB, policy: max_file_bytes)
  • packed-program (Windows) file_delta_pct: +8.1% exceeds limit of 3.0% (exceeded by +5.1pp, policy: max_delta_pct)

Add/update baselines:

.ci/size-gate/x86_64-pc-windows-msvc.toml:

[artifacts.baml-cli]
file_bytes = 82832384
stripped_bytes = 82832384
gzip_bytes = 27814411
[artifacts.packed-program]
file_bytes = 30711093
gzip_bytes = 10670634

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.

1 participant