Skip to content

[bug] Cascading duplicate diagnostics #2511

@AntennaeVY

Description

@AntennaeVY

Product

BAML

Describe the bug

When type-checking a chained binary expression like a + b + c + d where identifiers are undeclared, the checker emits multiple Invalid binary operation: cannot infer type of operands errors in addition to the expected Unknown variable … errors.

These operator-level diagnostics are cascades from the undeclared names and should be suppressed to avoid noise since inflated error counts and noisy output make real issues harder to spot and degrade developer UX.

Reproduction Steps

  1. Create a .baml file
function SevenErrors() -> int {
    a + b + c + d
}
  1. Run the check or generate command
  2. Observe the diagnostics
error: Error validating: Unknown variable a
  -->  file.baml:2
 2 |     a + b + c + d

error: Error validating: Unknown variable b
  -->  file.baml:2
 2 |     a + b + c + d

error: Error validating: Invalid binary operation: cannot infer type of operands
  -->  file.baml:2
 2 |     a + b + c + d

error: Error validating: Unknown variable c
  -->  file.baml:2
 2 |     a + b + c + d

error: Error validating: Invalid binary operation: cannot infer type of operands
  -->  file.baml:2
 2 |     a + b + c + d

error: Error validating: Unknown variable d
  -->  file.baml:2
 2 |     a + b + c + d

error: Error validating: Invalid binary operation: cannot infer type of operands
  -->  file.baml:2
 2 |     a + b + c + d

BAML Version

No response

Language/Framework

None

LLM Provider

None

LLM Model

No response

Operating System

Linux

Browser

None

Code Editor

None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions