{"record":{"id":"eff13888796f9ff1","repo":"BoundaryML/baml","slug":"interned-member-name-cannot-be-another-member-s-child","errorCode":null,"errorMessage":"interned member `{name}` cannot be another member's child","messagePattern":"interned member `(.+?)` cannot be another member's child","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_type_macros/src/parse.rs","lineNumber":329,"sourceCode":"        let resolved_members = members\n            .iter()\n            .enumerate()\n            .map(|(i, m)| {\n                let includes = m\n                    .includes\n                    .iter()\n                    .map(&axis_index)\n                    .collect::<syn::Result<Vec<_>>>()?;\n                let child = match &m.child {\n                    ChildRef::SelfRef => Child::Member(i),\n                    ChildRef::Named(name) => {\n                        let idx = member_index(name)?;\n                        // A plain member cannot nest an interned member: the\n                        // structural conversion walkers would have to convert\n                        // through a handle, which only the hand-written\n                        // boundary conversions can do.\n                        if matches!(members[idx].child, ChildRef::Interned(_)) {\n                            return Err(syn::Error::new(\n                                name.span(),\n                                format!(\n                                    \"interned member `{name}` cannot be another member's child\"\n                                ),\n                            ));\n                        }\n                        Child::Member(idx)\n                    }\n                    ChildRef::Interned(handle) => {\n                        if m.name == master_ident {\n                            return Err(syn::Error::new(\n                                m.name.span(),\n                                \"the master member cannot be interned: the master is the \\\n                                 plain tree every other member converts through\",\n                            ));\n                        }\n                        Child::Interned(Box::new(handle.clone()))\n                    }","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_type_macros/src/parse.rs#L311-L347","documentation":"A derive macro for BAML's interned type families rejects a plain (non-interned) member whose child is an interned member. This is structurally impossible to support because automatic conversion walkers cannot convert through a handle; only hand-written boundary conversions can. The macro fails at parse/derivation time before any code is generated.","triggerScenarios":"Declaring a derive input where `member_index(name)` resolves to a member whose `ChildRef` is `ChildRef::Interned(_)` — i.e. writing a plain member that nests another member marked as interned.","commonSituations":"Developers mixing plain and interned members in one type-family definition, assuming arbitrary nesting works; or refactoring a plain tree to add interning and marking the wrong level interned.","solutions":["Make the child member plain (remove its interning) so nesting stays in the walker-convertible plain tree.","Convert the parent into an interned member too, so the nesting lives behind a handle processed by boundary conversions.","Restructure so interned members only appear at the top level, not as children of other members."],"exampleFix":"// before\nmember Plain {\n  child: InternedMember,\n}\n// after\nmember Plain {\n  child: PlainChild,\n}\nmember PlainChild { /* plain fields */ }","handlingStrategy":"validation","validationCode":"// at macro-input authoring time\nassert!(!members.iter().any(|m| matches!(m.child, ChildRef::Interned(_))),\n    \"plain members must not nest interned members\");","typeGuard":"fn is_plain_child(m: &Member) -> bool { !matches!(m.child, ChildRef::Interned(_)) }","tryCatchPattern":null,"preventionTips":["Keep interned members at the top level of the family only","Document which members are interned in the type-family definition","Run the derive on a minimal fixture in CI to catch structure errors early"],"tags":["proc-macro","compile-time","baml","rust"],"backgroundTag":"schema-validation-failed","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}