{"record":{"id":"5472e6288c66ca10","repo":"typst/typst","slug":"cannot-mutate-fields-on-ty","errorCode":null,"errorMessage":"cannot mutate fields on {ty}","messagePattern":"cannot mutate fields on (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/typst-eval/src/access.rs","lineNumber":93,"sourceCode":"\npub(crate) fn access_dict<'a>(\n    vm: &'a mut Vm,\n    access: ast::FieldAccess,\n) -> SourceResult<&'a mut Dict> {\n    match access.target().access(vm)? {\n        Value::Dict(dict) => Ok(dict),\n        value => {\n            let ty = value.ty();\n            let span = access.target().span();\n            if matches!(\n                value, // those types have their own field getters\n                Value::Symbol(_)\n                    | Value::Content(_)\n                    | Value::Module(_)\n                    | Value::Func(_)\n                    | Value::Args(_)\n            ) {\n                bail!(span, \"cannot mutate fields on {ty}\");\n            } else if typst_library::foundations::fields_on(ty).is_empty() {\n                bail!(span, \"{ty} does not have accessible fields\");\n            } else {\n                // type supports static fields, which don't yet have\n                // setters\n                Err(eco_format!(\"fields on {ty} are not yet mutable\"))\n                    .hint(eco_format!(\n                        \"try creating a new {ty} with the updated field value instead\"\n                    ))\n                    .at(span)\n            }\n        }\n    }\n}\n","sourceCodeStart":75,"sourceCodeEnd":108,"githubUrl":"https://github.com/typst/typst/blob/35417aa769ab9d699a60384f91082b09bc6ba421/crates/typst-eval/src/access.rs#L75-L108","documentation":"From access_dict in the evaluator: a field-mutating operation (like `obj.field = x` or `obj.field += y`) targeted a value whose type is one of symbol/content/module/function/args — types that expose read-only named fields via their own getters rather than a mutable dictionary. The at-fault input is the target value of such a type.","triggerScenarios":"Thrown at crates/typst-eval/src/access.rs:93 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Mutate a dictionary instead of these read-only field types","Wrap the data in your own dictionary and mutate that","Rebuild the value (e.g. with a show rule or constructor) instead of mutating its fields"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"35417aa769ab9d699a60384f91082b09bc6ba421","analyzedAt":"2026-08-17T21:03:48.984Z","contentChangedAt":"2026-08-17T21:03:48.984Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}