{"record":{"id":"b5229c815b6034c0","repo":"GraphiteEditor/Graphite","slug":"failed-to-parse-node-function-e","errorCode":null,"errorMessage":"Failed to parse node function:\n{e}","messagePattern":"Failed to parse node function:\n(.+?)","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"node-graph/node-macro/src/parsing.rs","lineNumber":1027,"sourceCode":"\t\t\"u8\" | \"u16\" | \"u32\" | \"u64\" | \"u128\" | \"usize\" | \"i8\" | \"i16\" | \"i32\" | \"i64\" | \"i128\" | \"isize\"\n\t)\n}\n\nfn parse_output(output: &ReturnType) -> syn::Result<Type> {\n\tmatch output {\n\t\tReturnType::Default => Ok(syn::parse_quote!(())),\n\t\tReturnType::Type(_, ty) => Ok((**ty).clone()),\n\t}\n}\n\nfn extract_attribute<'a>(attrs: &'a [Attribute], name: &str) -> Option<&'a Attribute> {\n\tattrs.iter().find(|attr| attr.path().is_ident(name))\n}\n\n// Modify the new_node_fn function to use the code generation\npub fn new_node_fn(attr: TokenStream2, item: TokenStream2) -> syn::Result<TokenStream2> {\n\tlet crate_ident = CrateIdent::default();\n\tlet mut parsed_node = parse_node_fn(attr, item.clone()).map_err(|e| Error::new(e.span(), format!(\"Failed to parse node function:\\n{e}\")))?;\n\tparsed_node.replace_impl_trait_in_input();\n\tcrate::validation::validate_node_fn(&parsed_node).map_err(|e| Error::new(e.span(), format!(\"Validation error:\\n{e}\")))?;\n\tgenerate_node_code(&crate_ident, &parsed_node).map_err(|e| Error::new(e.span(), format!(\"Failed to generate node code:\\n{e}\")))\n}\n\nimpl ParsedNodeFn {\n\t/// The node's primary: the first argument (non-environment) field, whose declared shape classifies the node\n\t/// as an element-wise kernel, aggregation, or generator. Returns the field with its index in `fields`.\n\tpub(crate) fn primary_input_field(&self) -> Option<(usize, &ParsedField)> {\n\t\tself.fields.iter().enumerate().find(|(_, field)| !field.is_environment())\n\t}\n\n\tpub fn replace_impl_trait_in_input(&mut self) {\n\t\tif let Type::ImplTrait(impl_trait) = self.input.ty.clone() {\n\t\t\tlet ident = Ident::new(\"_Input\", impl_trait.span());\n\t\t\tlet mut bounds = impl_trait.bounds;\n\t\t\tbounds.push(parse_quote!('n));\n\t\t\tself.fn_generics.push(GenericParam::Type(TypeParam {","sourceCodeStart":1009,"sourceCodeEnd":1045,"githubUrl":"https://github.com/GraphiteEditor/Graphite/blob/c507b356453361e31638b8bff8f6d46b6da2961e/node-graph/node-macro/src/parsing.rs#L1009-L1045","documentation":"The outermost wrapper in new_node_fn: it re-reports any failure from parse_node_fn — malformed #[node(...)] attributes, an annotated item that is not a valid function, or invalid parameter/output syntax — prefixed with this message at the original span. Expect nested text: \"Failed to parse node function:\\nFailed to parse node_fn attributes:\\n...\".","triggerScenarios":"Applying #[node_macro::node(...)] to anything that is not a plain ItemFn (struct, impl block, trait method); Rust syntax errors inside the function signature or body; any of the inner attribute/parameter parse failures (errors 8–13) surfacing through this wrapper.","commonSituations":"Refactoring a node function into a struct-based node and leaving the attribute attached; large multi-error diffs where the actionable cause is the appended inner message, not this header.","solutions":["Read the indented inner message — it carries the actual cause and span; fix that first","Ensure the annotated item is a plain fn declaration","Re-run cargo check after fixing the inner error; this wrapper disappears along with it"],"exampleFix":"// before: node attribute on a struct\n#[node_macro::node(category(\"Value\"))]\nstruct MyNode;\n\n// after: annotate a plain function\n#[node_macro::node(category(\"Value\"))]\nfn my_node(input: f64) -> f64 { input }","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Apply node macros only to plain fn items","Read the nested inner message first — the wrapper text is not the cause","Run cargo check after structural refactors of node modules"],"tags":["proc-macro","rust","node-graph","compile-time"],"backgroundTag":"proc-macro-syntax-error","analyzedSha":"c507b356453361e31638b8bff8f6d46b6da2961e","analyzedAt":"2026-08-16T21:57:18.596Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}