{"record":{"id":"daf802b97fdcbada","repo":"BoundaryML/baml","slug":"complex-assignment-targets-not-yet-supported","errorCode":null,"errorMessage":"Complex assignment targets not yet supported","messagePattern":"Complex assignment targets not yet supported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-compiler/src/thir/interpret.rs","lineNumber":1546,"sourceCode":"                        \"array assignment requires a non-negative integer index at {:?}\",\n                        meta.0\n                    ),\n                };\n\n                match &mut base_value {\n                    BamlValueWithMeta::List(items, _) => {\n                        if idx >= items.len() {\n                            bail!(\"array assignment index out of bounds\");\n                        }\n                        items[idx] = value_to_assign.clone();\n                    }\n                    _ => bail!(\"array assignment on non-list value at {:?}\", meta.0),\n                }\n\n                value_to_assign = base_value;\n                current_expr = base.as_ref();\n            }\n            _ => return Err(anyhow!(\"Complex assignment targets not yet supported\")),\n        }\n    }\n}\n\nfn lookup(scopes: &[Scope], name: &str) -> Option<BamlValueWithMeta<ExprMetadata>> {\n    for s in scopes.iter().rev() {\n        if let Some(cell) = s.variables.get(name) {\n            return Some(cell.lock().unwrap().clone());\n        }\n    }\n    None\n}\n\nfn lookup_cell(\n    scopes: &[Scope],\n    name: &str,\n) -> Option<Arc<Mutex<BamlValueWithMeta<ExprMetadata>>>> {\n    for s in scopes.iter().rev() {","sourceCodeStart":1528,"sourceCodeEnd":1564,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-compiler/src/thir/interpret.rs#L1528-L1564","documentation":"The interpreter's assignment-target desugaring handles only plain variables, field accesses (`a.b`), and array accesses (`a[i]`). Any other expression shape used as an assignment target reaches the catch-all `_` arm and returns `Complex assignment targets not yet supported` — this is an intentional unimplemented-feature error, not a data problem.","triggerScenarios":"Assigning to nested targets like `a.b.c = v`, `arr[0][1] = v`, or any expression other than `Expr::Var`, `Expr::FieldAccess`, or `Expr::ArrayAccess` on the left of `=`.","commonSituations":"Porting nested mutation code from Python/JS into BAML; generated BAML code that assumes nested assignment support; attempting destructuring-style targets.","solutions":["Flatten the assignment: read the nested value into a local, mutate, then reassign the outer container","Restructure code so only top-level variable/field/array targets are assigned","If nested assignment is essential, request/upstream support in baml-compiler's `assign_to_expr`","Split the mutation into multiple single-level assignments"],"exampleFix":"// before\nmatrix[0][1] = 9; // complex target\n// after\nlet row = matrix[0];\nlet row2 = row + []; // rebuild row with the updated element\n// then rebind the outer variable with the new row","handlingStrategy":"fallback","validationCode":"// keep assignment targets single-level:\n// allowed: var, var.field, var[i]","typeGuard":null,"tryCatchPattern":"// host-side\nmatch result {\n    Err(e) if e.to_string().contains(\"Complex assignment targets\") => {\n        // rewrite/normalize the AST to flattened assignments before retry\n    }\n    other => other?,\n}","preventionTips":["Avoid nested assignment targets in BAML code","Flatten mutations into local variable rebinding","Check baml-compiler release notes before relying on new assignment forms"],"tags":["baml","interpreter","assignment","unsupported-feature"],"backgroundTag":"unsupported-operation","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"}