BoundaryML/baml · error
toLowerCase() method takes no arguments at {:?}
Error message
toLowerCase() method takes no arguments at {:?} What it means
THIR interpreter runtime error: `toLowerCase()` was invoked with arguments. The builtin string method takes none; any arguments at the call site are a mistake and abort evaluation with the expression location attached.
Source
Thrown at engine/baml-compiler/src/thir/interpret.rs:2843
}
Ok(BamlValueWithMeta::Int(map.len() as i64, meta.clone()))
}
_ => bail!(
"length() method not available on type {:?} at {:?}",
receiver,
meta.0
),
}
}
"toLowerCase" => {
let BamlValueWithMeta::String(s, _) = receiver else {
bail!(
"toLowerCase() method only available on strings at {:?}",
meta.0
);
};
if !args.is_empty() {
bail!("toLowerCase() method takes no arguments at {:?}", meta.0);
}
Ok(BamlValueWithMeta::String(s.to_lowercase(), meta.clone()))
}
"toUpperCase" => {
let BamlValueWithMeta::String(s, _) = receiver else {
bail!(
"toUpperCase() method only available on strings at {:?}",
meta.0
);
};
if !args.is_empty() {
bail!("toUpperCase() method takes no arguments at {:?}", meta.0);
}
Ok(BamlValueWithMeta::String(s.to_uppercase(), meta.clone()))
}
"trim" => {
let BamlValueWithMeta::String(s, _) = receiver else {
bail!("trim() method only available on strings at {:?}", meta.0);View on GitHub (pinned to bd85ce9dee)
Solutions
- Call toLowerCase() with empty parentheses
- Remove any locale or extra arguments; the BAML builtin performs an unconditional lowercase
Example fix
// before
let lower = name.toLowerCase("en-US")
// after
let lower = name.toLowerCase() Defensive patterns
Strategy: validation
Validate before calling
if !args.is_empty() {
return Err("toLowerCase() takes no arguments".into());
} Type guard
fn is_string(v: &BamlValueWithMeta<ExprMetadata>) -> bool {
matches!(v, BamlValueWithMeta::String(_, _))
} Prevention
- Call toLowerCase() with empty parentheses
- Do not port locale arguments from other languages
- Lint generated code for extra arguments on zero-arg methods
When it happens
Trigger: Evaluating s.toLowerCase(arg) with a non-empty argument list, regardless of argument type.
Common situations: Porting locale-aware lowercase calls (e.g. toLowerCase(locale)) from other languages; accidentally passing extra arguments in generated code.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- length() method takes no arguments at {:?}
- toLowerCase() method only available on strings at {:?}
- env.get expects exactly one argument
- baml.media.image.from_url expects 1 argument, got {} at {:?}
- baml.fetch_as expects 1 argument (url), got {} at {:?}
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/2895251578cf5dd2.
Report an issue: GitHub.