Skip to content

baml_language: add duplicate parameter error#3518

Merged
codeshaunted merged 1 commit into
canaryfrom
avery/dup-params-error
May 12, 2026
Merged

baml_language: add duplicate parameter error#3518
codeshaunted merged 1 commit into
canaryfrom
avery/dup-params-error

Conversation

@codeshaunted
Copy link
Copy Markdown
Collaborator

@codeshaunted codeshaunted commented May 12, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Compiler now detects and reports duplicate parameter names in both functions and lambda expressions. This improved validation catches parameter naming conflicts early, preventing potential runtime issues.
  • Tests

    • Added comprehensive test coverage for duplicate parameter detection to ensure the validation works correctly for both duplicate and distinct parameter names.

Review Change Stack

@vercel
Copy link
Copy Markdown

vercel Bot commented May 12, 2026

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

Project Deployment Actions Updated (UTC)
beps Ready Ready Preview, Comment May 12, 2026 7:40pm
promptfiddle Ready Ready Preview, Comment May 12, 2026 7:40pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1a4f2664-db01-4558-a837-e718c5653a5b

📥 Commits

Reviewing files that changed from the base of the PR and between 790a8bd and 14d2a17.

📒 Files selected for processing (2)
  • baml_language/crates/baml_compiler2_hir/src/builder.rs
  • baml_language/crates/baml_tests/src/compiler2_hir.rs

📝 Walkthrough

Walkthrough

This PR adds duplicate function and lambda parameter name detection to the compiler's semantic analysis. A new helper emits diagnostics when parameter lists contain repeated names, integrated into both lambda and function processing during HIR construction with comprehensive test coverage.

Changes

Duplicate Parameter Detection

Layer / File(s) Summary
Duplicate detection implementation and integration
baml_language/crates/baml_compiler2_hir/src/builder.rs
New emit_duplicate_param_diagnostics helper maps parameter names to their definition sites and delegates duplicate reporting to existing emit_duplicate_diagnostics. Method is called in walk_lambda_expr and lower_function to diagnose duplicate parameter names in both lambdas and regular functions.
Test coverage for duplicate parameter detection
baml_language/crates/baml_tests/src/compiler2_hir.rs
One test verifies duplicate function parameters across positional/defaulted combinations emit exactly one DuplicateDefinition diagnostic with two Parameter-kind sites. Regression test confirms distinct parameter names produce no diagnostics.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A rabbit hops through parameter lists with glee,
Spotting doubles—twice the name, but errors we see!
Lambda and function both now check with care,
Duplicate params caught, diagnostics laid bare! 🌟

🚥 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 accurately summarizes the main change: adding duplicate parameter error detection for both functions and lambdas in the BAML compiler.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 avery/dup-params-error

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

@codeshaunted codeshaunted enabled auto-merge May 12, 2026 19:32
@github-actions
Copy link
Copy Markdown

Binary size checks failed

1 violations · ✅ 6 passed

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

Artifact Platform Gzip Baseline Delta Status
bridge_cffi Linux 6.6 MB 6.4 MB +152.2 KB (+2.4%) FAIL
bridge_cffi-stripped Linux 5.6 MB 5.7 MB -52.1 KB (-0.9%) OK
bridge_cffi macOS 5.4 MB 5.1 MB +325.7 KB (+6.4%) OK
bridge_cffi-stripped macOS 4.6 MB 4.7 MB -52.8 KB (-1.1%) OK
bridge_cffi Windows 5.4 MB 5.1 MB +284.0 KB (+5.6%) OK
bridge_cffi-stripped Windows 4.7 MB 4.7 MB +21.5 KB (+0.5%) OK
bridge_wasm WASM 3.6 MB 3.5 MB +43.2 KB (+1.2%) OK
Details & how to fix

Violations:

  • bridge_cffi (Linux) gzip_bytes: 6.6 MB exceeds limit of 6.5 MB (exceeded by +87.9 KB, policy: max_gzip_bytes)

Add/update baselines:

.ci/size-gate/x86_64-unknown-linux-gnu.toml:

[artifacts.bridge_cffi]
file_bytes = 17655608
stripped_bytes = 17655600
gzip_bytes = 6587944

Generated by cargo size-gate · workflow run

@codeshaunted codeshaunted added this pull request to the merge queue May 12, 2026
Merged via the queue into canary with commit b602e7d May 12, 2026
45 of 47 checks passed
@codeshaunted codeshaunted deleted the avery/dup-params-error branch May 12, 2026 20:15
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