{"record":{"id":"05123df062f6f7e5","repo":"BoundaryML/baml","slug":"split-interface-matched-an-interface","errorCode":null,"errorMessage":"split_interface matched an interface","messagePattern":"split_interface matched an interface","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_compiler2_emit/src/lib.rs","lineNumber":1032,"sourceCode":"                mut interface_assoc,\n                for_ty,\n                for_ty_pattern,\n                impl_params,\n                impl_bounds,\n                generic_param_bounds,\n            }) = impl_rule_target(db, *file, impl_loc, resolved)\n            else {\n                continue;\n            };\n            interface_assoc.extend(lower_assoc(\n                store,\n                &block.associated_type_bindings,\n                &impl_params,\n                &impl_bounds,\n            ));\n            let iface_arg_tys = match &iface_ty {\n                ty::Ty::Interface(_, args, _, _) => args.clone(),\n                _ => unreachable!(\"split_interface matched an interface\"),\n            };\n            complete_interface_assoc(\n                &mut interface_assoc,\n                &iface_tn,\n                &iface_arg_tys,\n                &for_ty,\n                &impl_params,\n                resolved,\n            );\n            // The constraint set was lowered (and fail-closed gated) inside\n            // `impl_rule_target`, so the bake, the decompose attribution,\n            // and the rule's `ImplCoherenceKey` all carry the identical\n            // canonicalized bounds.\n            // A block's own method is compiled against the owner frame — the\n            // impl's declared generics, which for an in-class block ARE the\n            // class's.\n            let impl_frame: Vec<bex_vm_types::TyTemplate> = (0..u32::try_from(impl_params.len())\n                .expect(\"generic arity fits u32\"))","sourceCodeStart":1014,"sourceCodeEnd":1050,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_compiler2_emit/src/lib.rs#L1014-L1050","documentation":"In `build_packages`, after `split_interface` matches an impl block against an interface, the code destructures the resulting `iface_ty` and asserts with `unreachable!` that it is a `ty::Ty::Interface`. The panic means `split_interface` reported a match but the reconstructed type is not an Interface variant — an internal desynchronization between the matching and construction steps.","triggerScenarios":"An impl block whose interface type was rebuilt into a different `Ty` variant (alias collapse, generic instantiation producing a non-Interface head) despite `split_interface` succeeding.","commonSituations":"Type-alias resolution changes that collapse interface types; refactors of `split_interface` that changed what it matches; canonicalization bugs with generic interfaces.","solutions":["Inspect `split_interface` to ensure the returned type is preserved as `Ty::Interface` through alias/canonicalization","Check whether a recent change makes interface heads collapse to aliases before this match","Update the match to handle the new variant or fix the earlier construction step","Reproduce with the failing impl block's source to identify the alias/instantiation path"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if !matches!(iface_ty, ty::Ty::Interface(_, _, _, _)) {\n    return Err(CompilerBug::SplitInterfaceNonInterface(iface_tn.clone()));\n}","typeGuard":"fn is_interface_ty(t: &ty::Ty) -> bool {\n    matches!(t, ty::Ty::Interface(_, _, _, _))\n}","tryCatchPattern":"std::panic::catch_unwind(|| build_packages(db))\n    .unwrap_or_else(|_| report_compiler_bug(\"split_interface produced non-interface type\"));","preventionTips":["Make split_interface return the exact matched Ty::Interface instead of reconstructing it","Test impl blocks whose interface is reached through a type alias","Keep canonicalization from collapsing interface heads"],"tags":["compiler","rust","panic","impl-blocks","interfaces"],"backgroundTag":"internal-invariant-violation","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"}