{"record":{"id":"ae1dc538fc48a5f0","repo":"tracel-ai/burn","slug":"only-literal-is-supported","errorCode":null,"errorMessage":"Only literal is supported","messagePattern":"Only literal is supported","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-derive/src/shared/attribute.rs","lineNumber":26,"sourceCode":"pub struct AttributeItem {\n    pub value: syn::Lit,\n}\n\nimpl AttributeAnalyzer {\n    pub fn new(attr: Attribute) -> Self {\n        Self { attr }\n    }\n\n    pub fn item(&self) -> AttributeItem {\n        let value = match &self.attr.meta {\n            Meta::List(val) => val.parse_args::<syn::MetaNameValue>().unwrap(),\n            Meta::NameValue(meta) => meta.clone(),\n            Meta::Path(_) => panic!(\"Path meta unsupported\"),\n        };\n\n        let lit = match value.value {\n            syn::Expr::Lit(lit) => lit.lit,\n            _ => panic!(\"Only literal is supported\"),\n        };\n\n        AttributeItem { value: lit }\n    }\n\n    pub fn has_name(&self, name: &str) -> bool {\n        Self::path_syn_name(self.attr.path()) == name\n    }\n\n    fn path_syn_name(path: &syn::Path) -> String {\n        let length = path.segments.len();\n        let mut name = String::new();\n        for (i, segment) in path.segments.iter().enumerate() {\n            if i == length - 1 {\n                name += segment.ident.to_string().as_str();\n            } else {\n                let tmp = segment.ident.to_string() + \"::\";\n                name += tmp.as_str();","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-derive/src/shared/attribute.rs#L8-L44","documentation":"Value-form guard in the same attribute parser: after extracting the attribute's value expression, only a literal (`Lit`) is accepted; computed expressions such as `#[attr(foo())]` or concatenations reach the fallback arm and panic at macro-expansion time. The failing input is a non-literal expression used as the attribute value.","triggerScenarios":"Thrown at crates/burn-derive/src/shared/attribute.rs:26 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Change the attribute value to a literal, e.g. #[my_attr = \"value\"] or #[my_attr(value)] where value parses to a syn::Lit, since AttributeAnalyzer::item only accepts syn::Expr::Lit.","If you need complex expressions in the attribute, extend the match arm in AttributeAnalyzer::item to handle the required syn::Expr variants instead of panicking.","Check for stray macro interpolation or concatenation in the attribute that produces a non-literal expression, and pre-compute the value so a plain literal appears in the source."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}