{"record":{"id":"e2f659e27ccfdb8d","repo":"BoundaryML/baml","slug":"touppercase-method-takes-no-arguments-at","errorCode":null,"errorMessage":"toUpperCase() method takes no arguments at {:?}","messagePattern":"toUpperCase\\(\\) method takes no arguments at (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-compiler/src/thir/interpret.rs","lineNumber":2855,"sourceCode":"                bail!(\n                    \"toLowerCase() method only available on strings at {:?}\",\n                    meta.0\n                );\n            };\n            if !args.is_empty() {\n                bail!(\"toLowerCase() method takes no arguments at {:?}\", meta.0);\n            }\n            Ok(BamlValueWithMeta::String(s.to_lowercase(), meta.clone()))\n        }\n        \"toUpperCase\" => {\n            let BamlValueWithMeta::String(s, _) = receiver else {\n                bail!(\n                    \"toUpperCase() method only available on strings at {:?}\",\n                    meta.0\n                );\n            };\n            if !args.is_empty() {\n                bail!(\"toUpperCase() method takes no arguments at {:?}\", meta.0);\n            }\n            Ok(BamlValueWithMeta::String(s.to_uppercase(), meta.clone()))\n        }\n        \"trim\" => {\n            let BamlValueWithMeta::String(s, _) = receiver else {\n                bail!(\"trim() method only available on strings at {:?}\", meta.0);\n            };\n            if !args.is_empty() {\n                bail!(\"trim() method takes no arguments at {:?}\", meta.0);\n            }\n            Ok(BamlValueWithMeta::String(\n                s.trim().to_string(),\n                meta.clone(),\n            ))\n        }\n        \"includes\" => {\n            let BamlValueWithMeta::String(s, _) = receiver else {\n                bail!(","sourceCodeStart":2837,"sourceCodeEnd":2873,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-compiler/src/thir/interpret.rs#L2837-L2873","documentation":"toUpperCase() in BAML takes no arguments; passing any argument to it makes evaluate_method_call bail. The method intentionally mirrors the zero-argument JavaScript/Rust to_uppercase, so any parenthesized argument is a compile/interpret-time error.","triggerScenarios":"Writing `s.toUpperCase(arg)` — with any number of arguments (even an empty literal or another string) — inside a BAML expression block or template expression.","commonSituations":"Develpers coming from languages where case-conversion takes a locale/culture argument (e.g. Java's toUpperCase(Locale)) pass an argument out of habit; copying a pattern from another string method like includes() that does take an argument.","solutions":["Remove the argument and call it as a no-argument method: `s.toUpperCase()`.","If locale- or prefix-specific casing was intended, perform that transformation outside BAML in the host language before passing the string in.","Check you didn't mean a different method — e.g. includes() or startsWith() do take one argument."],"exampleFix":"// before\nlet upper = name.toUpperCase(\"en-US\");\n// after\nlet upper = name.toUpperCase();","handlingStrategy":"validation","validationCode":"// lint your BAML sources before running\nconst bad = src.match(/\\.toUpperCase\\s*\\(\\s*[^)]+/);\nif (bad) throw new Error('toUpperCase() takes no arguments: ' + bad[0]);","typeGuard":null,"tryCatchPattern":"try {\n  const res = await b.Function(args);\n} catch (e) {\n  if (String(e.message).includes('toUpperCase() method takes no arguments')) {\n    // strip the argument at the reported span and re-run\n  }\n  throw e;\n}","preventionTips":["Remember BAML string methods mirror zero-argument JS string methods.","Add a regex lint for `toUpperCase(` followed by non-empty args in BAML files.","Handle locale-specific casing in the host language, not in BAML expressions."],"tags":["baml","interpreter","string-methods","wrong-arity"],"backgroundTag":"missing-required-argument","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}