{"record":{"id":"35b7f0b451cea13c","repo":"BoundaryML/baml","slug":"interface-iface-wire-declares-a-non-runtime-constraint-e","errorCode":null,"errorMessage":"interface `{iface_wire}` declares a non-runtime constraint: {e:?}","messagePattern":"interface `(.+?)` declares a non-runtime constraint: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_compiler2_emit/src/lib.rs","lineNumber":162,"sourceCode":"                       store: &TypeRefStore,\n                       id: TypeRefId|\n     -> Option<bex_vm_types::RuntimeInterface> {\n        // ConstraintHead, per the contract above: the default (existential)\n        // position eagerly realizes omitted associated defaults and fills\n        // the rest with Error sentinels — a bound like `type A extends\n        // Iface` with unpinned associated types would panic `to_runtime`.\n        let lowered = baml_compiler2_hir_ty::lower::reject_holes(&ctx.lower_type_ref_at(\n            store,\n            id,\n            baml_compiler2_hir_ty::lower::TypePosition::ConstraintHead,\n        ));\n        let baml_type::Ty::Interface(qtn, args, assoc, _) = lowered else {\n            return None;\n        };\n        let to_runtime = |t: &baml_type::Ty| {\n            baml_type::lower_to_runtime(t, resolved.aliases)\n                .unwrap_or_else(|e| {\n                    unreachable!(\n                        \"interface `{iface_wire}` declares a non-runtime constraint: {e:?}\"\n                    )\n                })\n                .map_heads(&mut |decl| resolved.wire(decl))\n        };\n        let generics = args.iter().map(to_runtime).collect();\n        let associated_types = assoc\n            .iter()\n            .map(|(n, t)| (n.clone(), to_runtime(t)))\n            .collect();\n        Some(bex_vm_types::anchor_interface(&RuntimeInterface::new(\n            resolved.wire(&qtn),\n            generics,\n            associated_types,\n        )))\n    };\n    // A method's runtime signature: Required params -> positional `args`,\n    // optional (defaulted) params -> `kwargs`; the `self` receiver is","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_compiler2_emit/src/lib.rs#L144-L180","documentation":"In `build_interface_def`, generic-argument and constraint types of an interface are converted to runtime types with `lower_to_runtime`, and any failure triggers this `unreachable!`. It asserts that every constraint (bound / `requires` target / associated-type bound) on an interface has a runtime representation once holes have been rejected.","triggerScenarios":"An interface whose generic argument or bound lowers to a non-runtime type (bare type variable head, function type, or other constraint-only type) reaches the `to_runtime` closure in build_interface_def.","commonSituations":"Interfaces with bounds referencing types the runtime cannot materialize; new `Ty` variants added to the type system without corresponding `lower_to_runtime` support.","solutions":["Rewrite the interface constraint to use a runtime-representable type","Fix the pre-lowering stage so constraint-only types are filtered before this point","Extend `baml_type::lower_to_runtime` if the constraint should be representable","Convert the `unreachable!` into a typed compiler error for better diagnostics"],"exampleFix":"// before\ninterface Foo<T: SomeConstraintOnlyType> { ... }\n// after\ninterface Foo<T: runtime.Supported> { ... }","handlingStrategy":"validation","validationCode":"for arg in &iface.generic_args {\n    if lower_to_runtime(arg, &aliases).is_none() {\n        return Err(TypeError::NonRuntimeConstraint(iface.name.clone()));\n    }\n}","typeGuard":null,"tryCatchPattern":"std::panic::catch_unwind(|| build_interface_def(resolved, store))\n    .unwrap_or_else(|_| report_compiler_bug(\"interface has non-runtime constraint\"));","preventionTips":["Filter constraint-only types before runtime lowering in build_interface_def","Keep lower_to_runtime coverage tests in sync with new Ty variants","Prefer a typed diagnostic over unreachable! for constraint lowering failures"],"tags":["compiler","rust","panic","interfaces","type-lowering"],"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"}