BoundaryML/baml · error

unsupported types for * operator at

Error message

unsupported types for * operator at {:?}

What it means

THIR interpreter runtime error: the binary `*` operator was applied to operand types with no defined multiplication. Only int/int, float/float, and mixed numeric pairs are supported; other combinations fall through to this bail, tagged with the expression location metadata.

Solutions

  1. Ensure both operands are Int or Float; convert explicitly if needed
  2. Parse numeric strings before multiplying
  3. Handle null/missing values before the operation
  4. For string repetition, use a loop or explicit helper instead of `*`

Example fix

// before
let total = price * "3";
// after
let total = price * toInt("3");
Defensive patterns

Strategy: validation

Validate before calling

if (typeof a !== 'number' || typeof b !== 'number') { throw new Error('multiplication requires numeric operands'); }

Type guard

function isNumeric(v) { return typeof v === 'number' && !Number.isNaN(v); }

Try / catch

try { result = a * b; } catch (e) { if (String(e).includes('unsupported types for *')) { /* convert to numbers and retry */ } else { throw e; } }

Prevention

When it happens

Trigger: Multiplying strings (e.g. JS-style repeat), nulls, booleans, or lists; a value from LLM output or config that is a string used in multiplication.

Common situations: Attempting `"ab" * 3` repetition which is unsupported; null from a failed expression; numeric strings from parsed output used directly in arithmetic.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/12aa253e40529fe1. Report an issue: GitHub.

Appendix: source

Thrown at engine/baml-compiler/src/thir/interpret.rs:2396

            (BamlValueWithMeta::Float(a, _), BamlValueWithMeta::Int(b, _)) => {
                BamlValueWithMeta::Float(a - (b as f64), meta.clone())
            }
            _ => bail!("unsupported types for - operator at {:?}", meta.0),
        },
        BinaryOperator::Mul => match (left_val.clone(), right_val.clone()) {
            (BamlValueWithMeta::Int(a, _), BamlValueWithMeta::Int(b, _)) => {
                BamlValueWithMeta::Int(a * b, meta.clone())
            }
            (BamlValueWithMeta::Float(a, _), BamlValueWithMeta::Float(b, _)) => {
                BamlValueWithMeta::Float(a * b, meta.clone())
            }
            (BamlValueWithMeta::Int(a, _), BamlValueWithMeta::Float(b, _)) => {
                BamlValueWithMeta::Float((a as f64) * b, meta.clone())
            }
            (BamlValueWithMeta::Float(a, _), BamlValueWithMeta::Int(b, _)) => {
                BamlValueWithMeta::Float(a * (b as f64), meta.clone())
            }
            _ => bail!("unsupported types for * operator at {:?}", meta.0),
        },
        BinaryOperator::Div => match (left_val.clone(), right_val.clone()) {
            (BamlValueWithMeta::Int(a, _), BamlValueWithMeta::Int(b, _)) => {
                if b == 0 {
                    bail!("division by zero at {:?}", meta.0);
                }
                BamlValueWithMeta::Float((a as f64) / (b as f64), meta.clone())
            }
            (BamlValueWithMeta::Float(a, _), BamlValueWithMeta::Float(b, _)) => {
                if b == 0.0 {
                    bail!("division by zero at {:?}", meta.0);
                }
                BamlValueWithMeta::Float(a / b, meta.clone())
            }
            (BamlValueWithMeta::Int(a, _), BamlValueWithMeta::Float(b, _)) => {
                if b == 0.0 {
                    bail!("division by zero at {:?}", meta.0);
                }

View on GitHub (pinned to bd85ce9dee)