{"record":{"id":"4ff70122a2930f2d","repo":"BoundaryML/baml","slug":"unsupported-atom-value","errorCode":null,"errorMessage":"unsupported atom: {value:#?}","messagePattern":"unsupported atom: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-compiler/src/codegen.rs","lineNumber":1111,"sourceCode":"\n                BamlValueWithMeta::Bool(v, _) => {\n                    let index = self.add_constant(Value::Bool(*v));\n                    self.emit(Instruction::LoadConst(index));\n                }\n\n                BamlValueWithMeta::Int(v, _) => {\n                    let index = self.add_constant(Value::Int(*v));\n                    self.emit(Instruction::LoadConst(index));\n                }\n\n                BamlValueWithMeta::Float(v, _) => {\n                    let index = self.add_constant(Value::Float(*v));\n                    self.emit(Instruction::LoadConst(index));\n                }\n\n                BamlValueWithMeta::String(v, _) => self.emit_string_literal(v),\n\n                _ => panic!(\"unsupported atom: {value:#?}\"),\n            },\n\n            thir::Expr::Block(block, _) => self.compile_block(block),\n\n            thir::Expr::ArrayAccess {\n                base,\n                index,\n                meta: _,\n            } => {\n                // ArrayAccess compilation for loading elements\n                //\n                // Steps to compile array[index] or map[key]:\n                // 1. Compile the base expression (array or map)\n                // 2. Compile the index/key expression\n                // 3. Determine the type from metadata (List or Map)\n                // 4. Emit the appropriate load instruction:\n                //    - LoadArrayElement for arrays (expects integer index)\n                //    - LoadMapElement for maps (expects string key)","sourceCodeStart":1093,"sourceCodeEnd":1129,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-compiler/src/codegen.rs#L1093-L1129","documentation":"Panic in expression codegen when an atom (literal) expression has a value kind the compiler does not know how to lower to bytecode. Only a fixed set of atom types (int, bool, float, string, null, etc.) is handled; the exhaustive match ends in a catch-all that panics with a debug dump of the value. This means the THIR contains an atom variant codegen was never taught to emit.","triggerScenarios":"Compiling an `Expr::Atom` whose `BamlValueWithMeta` payload is not one of the explicitly matched literal kinds — e.g. a compound value (map, class instance, media object) reached codegen as an atom.","commonSituations":"Newly added value kinds in the IR not yet handled in codegen; media or nested-struct values appearing where only scalars are expected; internal desugaring bugs that fail to expand compound atoms before codegen.","solutions":["Identify the atom variant printed in the panic message and confirm whether your source expression can be rewritten to use only scalar literals","Refactor the expression so the compound value is constructed via its proper expression form instead of appearing as an atom","Upgrade/patch the compiler to add a codegen arm for the missing atom variant","File an issue with the `{value:#?}` dump — this is an unhandled compiler case, not a source-level error"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Only pass scalar literals where atoms are expected\nfn is_supported_atom(v: &Value) -> bool {\n    matches!(v, Value::Int(_) | Value::Float(_) | Value::String(_) | Value::Bool(_) | Value::Null)\n}","typeGuard":"fn as_scalar_atom(v: &BamlValue) -> Option<&BamlValue> {\n    match v { BamlValue::Int(_) | BamlValue::Float(_) | BamlValue::String(_) | BamlValue::Bool(_) | BamlValue::Null(_) => Some(v), _ => None }\n}","tryCatchPattern":"match std::panic::catch_unwind(|| compiler.compile(src)) {\n    Ok(out) => out,\n    Err(_) => { eprintln!(\"compiler hit an unhandled atom kind; check literal forms in source\"); std::process::exit(1); }\n}","preventionTips":["Use only scalar literals where atom expressions are expected; build compound values via constructors","Keep the compiler updated so new IR value kinds are handled in codegen","Capture panic dumps (`{value:#?}`) when reporting issues"],"tags":["compiler","codegen","panic","unsupported-value"],"backgroundTag":"internal-invariant-violation","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"}