gleam-lang/gleam · error
uninferred constructor made it to codegen
Error message
uninferred constructor made it to codegen
What it means
An internal compiler assertion raised while generating Erlang code for a constructor pattern: the pattern's `constructor` field holds Inferred::Unknown instead of a known PatternConstructor. Constructor names must be resolved during type inference before codegen, so an uninferred constructor indicates an earlier phase failed to annotate the pattern.
Solutions
- Fix any type errors reported earlier in the module; unresolved inference is often downstream of them.
- Update gleam to the latest version.
- Reduce to a minimal module and file a bug at github.com/gleam-lang/gleam if no prior error was reported.
Defensive patterns
Strategy: validation
Validate before calling
// Ensure inference completed: build and fix all reported type errors before codegen gleam check || exit 1
Type guard
let Inferred::Known(constructor) = &pattern.constructor else { return Err(...); }; Try / catch
let status = Command::new("gleam").args(["build"]).status()?;
if !status.success() { /* treat as compiler failure */ } Prevention
- Run `gleam check` and clear all type errors before building.
- Match only on values of fully resolved custom types.
- Report uninferred-constructor panics with a minimal reproducer.
When it happens
Trigger: Generating code for a Pattern::Constructor whose type inference did not resolve its constructor (e.g. inference was interrupted by earlier errors, or a compiler bug left the inference unresolved).
Common situations: Compiling code with pattern matches on custom types where an earlier inference error occurred; usually accompanied by prior error diagnostics; otherwise a compiler bug.
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
- invalid patterns should not reach code generation
- invalid constants should not reach code generation
- invalid pattern inside aliased bit array pattern segment
- invalid size in pattern size segment
- record updates should not reach code generation
AI-assisted analysis of gleam-lang/gleam@15b07c7830 (2026-09-14).
Data as JSON: /api/errors/692cdef2d5d8f34a.
Report an issue: GitHub.
Appendix: source
Thrown at compiler-core/src/erlang/pattern.rs:207
if let Some(tail) = tail {
self.pattern(builder, &tail.pattern);
} else {
builder.empty_list_pattern(SrcSpan {
start: location.end,
end: location.end,
});
}
}
Pattern::Constructor {
arguments,
constructor,
location,
name_location,
..
} => {
let Inferred::Known(PatternConstructor { name, .. }) = constructor else {
panic!("uninferred constructor made it to codegen ")
};
if arguments.is_empty() {
builder.atom_pattern(*name_location, &to_snake_case(name));
} else {
let tuple = builder.start_tuple_pattern(*location);
builder.atom_pattern(*name_location, &to_snake_case(name));
for argument in arguments {
self.pattern(builder, &argument.value);
}
builder.end_tuple_pattern(tuple);
}
}
Pattern::StringPrefix {
left_side_string,
left_side_assignment,
right_side_assignment,View on GitHub (pinned to 15b07c7830)