{"record":{"id":"6c42e9b48660ad1c","repo":"risingwavelabs/risingwave","slug":"expected-literal","errorCode":null,"errorMessage":"expected literal","messagePattern":"expected literal","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/expr/macro/src/parse.rs","lineNumber":62,"sourceCode":"        parsed.name = name.trim().to_owned();\n        parsed.args = if args.is_empty() {\n            vec![]\n        } else {\n            args.split(',').map(|s| s.trim().to_owned()).collect()\n        };\n        parsed.ret = ret.trim().to_owned();\n        parsed.is_table_function = is_table_function;\n\n        if input.parse::<Token![,]>().is_err() {\n            return Ok(parsed);\n        }\n\n        let metas = input.parse_terminated(syn::Meta::parse, Token![,])?;\n        for meta in metas {\n            let get_value = || {\n                let kv = meta.require_name_value()?;\n                let syn::Expr::Lit(lit) = &kv.value else {\n                    return Err(Error::new(kv.value.span(), \"expected literal\"));\n                };\n                let syn::Lit::Str(lit) = &lit.lit else {\n                    return Err(Error::new(kv.value.span(), \"expected string literal\"));\n                };\n                Ok(lit.value())\n            };\n            if meta.path().is_ident(\"batch_fn\") {\n                parsed.batch_fn = Some(get_value()?);\n            } else if meta.path().is_ident(\"state\") {\n                parsed.state = Some(get_value()?);\n            } else if meta.path().is_ident(\"init_state\") {\n                parsed.init_state = Some(get_value()?);\n            } else if meta.path().is_ident(\"prebuild\") {\n                parsed.prebuild = Some(get_value()?);\n            } else if meta.path().is_ident(\"type_infer\") {\n                parsed.type_infer = Some(get_value()?);\n            } else if meta.path().is_ident(\"generic\") {\n                parsed.generic = Some(get_value()?);","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/expr/macro/src/parse.rs#L44-L80","documentation":"When parsing the attribute list of a `#[function(...)]` declaration, each recognized key (`batch_fn`, `state`, `prebuild`, etc.) must be given a string literal value via `get_value()`. If the value after `=` is an expression but not a literal (e.g. a path, macro call, or concatenation), the parser emits this spanned error.","triggerScenarios":"Writing `#[function(\"sig(int4)\", batch_fn = some_const)]`, `prebuild = concat!(\"a\", \"b\")`, or any non-literal expression after a key that requires a string value.","commonSituations":"Developers trying to share/configure attribute values through constants or macro-generated strings, which Rust proc-macro attribute parsing here does not support.","solutions":["Replace the expression with a plain string literal: `batch_fn = \"...\"`.","Inline whatever the constant or macro produced as a literal string.","Compute the value at build time with a build script only if truly dynamic — the attribute itself must stay a literal."],"exampleFix":"// before\n#[function(\"my_add(int4, int4)\", batch_fn = MY_BATCH_FN)]\n\n// after\n#[function(\"my_add(int4, int4)\", batch_fn = \"my_add_batch\")]","handlingStrategy":"validation","validationCode":"// Attribute values must be plain string literals\nmacro_rules! check_attr { ($k:literal = $v:expr) => { const { assert!(matches!($v, _: &'static str)); } } }\n// Simplest guard: review that every key=value uses quotes:\n//   GOOD: batch_fn = \"name\"   BAD: batch_fn = some_const","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always write attribute values as double-quoted string literals; no constants, no concat!(), no paths.","If you need reuse, generate the whole #[function] invocation from a declarative macro instead of parameterizing the value.","Compile early with cargo check on the expr crate after editing attributes."],"tags":["proc-macro","compile-time","attribute","syntax"],"backgroundTag":"invalid-argument-value","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}