gleam-lang/gleam · error
Hydrator must not store non generic types here
Error message
Hydrator must not store non generic types here
What it means
An internal invariant panic in the Gleam type hydrator (`type_.rs:1108`). While collecting generic type parameters, the hydrator expects every stored type entry to be a `Type::Var` wrapping a `TypeVar::Generic`. If it finds an `Unbound`/`Link` type variable, or a concrete `Named`/`Fn`/`Tuple` type, it panics because the hydrator was populated with non-generic types — meaning an earlier type-annotation phase failed to register only generic parameters.
Solutions
- This is a compiler-internal invariant: report it as a bug to the Gleam repository with the exact source snippet and compiler version that triggered it.
- Check the type annotation at the reported location for misuse of concrete types where type parameters are expected, and simplify the annotation.
- If you are modifying the compiler, fix the code path that inserts non-generic types into the hydrator (only generic `TypeVar`s should be stored).
- Try upgrading or downgrading the Gleam version — this may be a known regression fixed in a later release.
Example fix
// before (registering a parameter without checking it is generic)
hydrator.store_type(name, concrete_type);
// after
if let Type::Var { type_ } = concrete_type.as_ref() {
if matches!(type_.borrow().deref(), TypeVar::Generic { .. }) {
hydrator.store_type(name, concrete_type);
}
} Defensive patterns
Strategy: validation
Validate before calling
// Rust: validate before storing into the hydrator
fn is_generic_var(t: &Type) -> bool {
matches!(
t,
Type::Var { type_ }
if matches!(&*type_.borrow(), TypeVar::Generic { .. })
)
} Type guard
fn is_generic_var(t: &Type) -> bool {
matches!(t, Type::Var { type_ } if matches!(&*type_.borrow(), TypeVar::Generic { .. }))
} Try / catch
// Panics are not catchable in Rust; the guard is to validate before insertion
assert!(
is_generic_var(¶m_type),
"hydrator parameters must be generic vars, got {:?}",
param_type
); Prevention
- Only insert types into the hydrator after verifying they are generic variables.
- When adding new annotation forms, add unit tests covering hydrator registration.
- Report any user-facing reproduction to the Gleam maintainers — this panic indicates a compiler bug.
When it happens
Trigger: During hydrator construction from a type annotation, a stored parameter resolves to a non-generic type: an unbound or linked type variable, or a fully concrete Named/Fn/Tuple type, is present in the hydrator's type map when generic parameter IDs are collected.
Common situations: A compiler bug in annotation parsing/instantiation; a malformed or exotic type annotation that confuses the hydrator (e.g. a value-type used where a generic parameter is expected); encountering it while hacking on the compiler itself or after a version upgrade changes inference behaviour.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- aliased non constant value
- channel buffer write
- Expression not fully reduced.
- invalid constants can not be in an untyped ast
- invalid expressions should not reach code generation
AI-assisted analysis of gleam-lang/gleam@15b07c7830 (2026-09-14).
Data as JSON: /api/errors/56580ff643b1d020.
Report an issue: GitHub.
Appendix: source
Thrown at compiler-core/src/type_.rs:1108
impl TypeVariantConstructors {
pub(crate) fn new(
variants: Vec<TypeValueConstructor>,
type_parameters: &[&EcoString],
opaque: Opaque,
hydrator: Hydrator,
) -> TypeVariantConstructors {
let named_types = hydrator.named_type_variables();
let type_parameters = type_parameters
.iter()
.map(|&p| {
let t = named_types
.get(p)
.expect("Type parameter not found in hydrator");
let error = "Hydrator must not store non generic types here";
match t.type_.as_ref() {
Type::Var { type_ } => match type_.borrow().deref() {
TypeVar::Generic { id } => *id,
TypeVar::Unbound { .. } | TypeVar::Link { .. } => panic!("{}", error),
},
Type::Named { .. } | Type::Fn { .. } | Type::Tuple { .. } => {
panic!("{}", error)
}
}
})
.collect_vec();
Self {
type_parameters_ids: type_parameters,
variants,
opaque,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct TypeValueConstructor {
pub name: EcoString,View on GitHub (pinned to 15b07c7830)