BoundaryML/baml · error
Complex assignment targets not yet supported
Error message
Complex assignment targets not yet supported
What it means
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.
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
Example fix
// before matrix[0][1] = 9; // complex target // after let row = matrix[0]; let row2 = row + []; // rebuild row with the updated element // then rebind the outer variable with the new row
Defensive patterns
Strategy: fallback
Validate before calling
// keep assignment targets single-level: // allowed: var, var.field, var[i]
Try / catch
// host-side
match result {
Err(e) if e.to_string().contains("Complex assignment targets") => {
// rewrite/normalize the AST to flattened assignments before retry
}
other => other?,
} Prevention
- Avoid nested assignment targets in BAML code
- Flatten mutations into local variable rebinding
- Check baml-compiler release notes before relying on new assignment forms
When it happens
Trigger: 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 `=`.
Common situations: Porting nested mutation code from Python/JS into BAML; generated BAML code that assumes nested assignment support; attempting destructuring-style targets.
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
- array assignment index out of bounds
- array assignment on non-list value at
- array assignment requires a non-negative integer index at
- assign to undeclared variable
- cannot assign function to variable
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/daf802b97fdcbada.
Report an issue: GitHub.
Appendix: source
Thrown at engine/baml-compiler/src/thir/interpret.rs:1546
"array assignment requires a non-negative integer index at {:?}",
meta.0
),
};
match &mut base_value {
BamlValueWithMeta::List(items, _) => {
if idx >= items.len() {
bail!("array assignment index out of bounds");
}
items[idx] = value_to_assign.clone();
}
_ => bail!("array assignment on non-list value at {:?}", meta.0),
}
value_to_assign = base_value;
current_expr = base.as_ref();
}
_ => return Err(anyhow!("Complex assignment targets not yet supported")),
}
}
}
fn lookup(scopes: &[Scope], name: &str) -> Option<BamlValueWithMeta<ExprMetadata>> {
for s in scopes.iter().rev() {
if let Some(cell) = s.variables.get(name) {
return Some(cell.lock().unwrap().clone());
}
}
None
}
fn lookup_cell(
scopes: &[Scope],
name: &str,
) -> Option<Arc<Mutex<BamlValueWithMeta<ExprMetadata>>>> {
for s in scopes.iter().rev() {View on GitHub (pinned to bd85ce9dee)