{"record":{"id":"81e18b1b77b4ce9d","repo":"neon-bindings/neon","slug":"expected-type-name","errorCode":null,"errorMessage":"Expected type name","messagePattern":"Expected type name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/neon-macros/src/export/class.rs","lineNumber":86,"sourceCode":"\n    // Combine the class implementation with the export registration\n    quote!(\n        #class_tokens\n        #create_fn\n    )\n    .into()\n}\n\n// Extract the class identifier from an impl block\nfn extract_class_ident(input: &syn::ItemImpl) -> syn::Result<syn::Ident> {\n    match &*input.self_ty {\n        syn::Type::Path(syn::TypePath {\n            path: syn::Path { segments, .. },\n            ..\n        }) => {\n            let syn::PathSegment { ident, .. } = segments\n                .last()\n                .ok_or_else(|| syn::Error::new(input.self_ty.span(), \"Expected type name\"))?;\n            Ok(ident.clone())\n        }\n        _ => Err(syn::Error::new(\n            input.self_ty.span(),\n            \"Class export can only be applied to named types\",\n        )),\n    }\n}\n","sourceCodeStart":68,"sourceCodeEnd":95,"githubUrl":"https://github.com/neon-bindings/neon/blob/38960e4381d9ad13b551cdf2d261f609167c9bc2/crates/neon-macros/src/export/class.rs#L68-L95","documentation":"When exporting a class with #[neon] export, the macro inspects the impl's self type and requires it to be a path to a named type whose path has at least one segment. An empty or unresolvable path segment yields this error at the self type span.","triggerScenarios":"Applying #[neon] on an impl whose self type resolves to a path with zero last segments (e.g. a parenthesized, tuple, reference-to-anonymous, or otherwise malformed type where segments.last() is None).","commonSituations":"Impl blocks with odd self types such as `impl &Greet`, `impl (Greet,)`, or types produced by complex macro expansion that are not simple named paths.","solutions":["Implement on the named type directly, e.g. `impl Greet` instead of `impl &Greet`","Remove references/generics wrappers from the self type so it is a simple named path","Check that macro-generated self types expand to a plain identifier"],"exampleFix":"// before\n#[neon]\nimpl &Greet { // self type is not a named path\n    fn new(cx: &mut FunctionContext) -> JsResult<JsGreet> { ... }\n}\n// after\n#[neon]\nimpl Greet {\n    fn new(cx: &mut FunctionContext) -> JsResult<JsGreet> { ... }\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// ensure the impl self type is a simple named path\nfn is_named_type(sig: &syn::ImplSignature) -> bool {\n    matches!(**sig.self_ty, syn::Type::Path(ref p) if !p.path.segments.is_empty())\n}","tryCatchPattern":null,"preventionTips":["Implement on concrete named structs/enums only","Avoid `&T`, tuples, or other non-path self types in exported impls","Check macro-expanded self types resolve to plain identifiers"],"tags":["rust","proc-macro","neon","self-type","compile-time"],"backgroundTag":"incompatible-source-type","analyzedSha":"38960e4381d9ad13b551cdf2d261f609167c9bc2","analyzedAt":"2026-09-13T09:05:33.640Z","contentChangedAt":"2026-09-13T09:05:33.640Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}