gleam-lang/gleam · error
This is an extra type specifier
Error message
This is an extra type specifier
What it means
Raised as ErrorType::ConflictingTypeOptions when a bit array segment specifies more than one type option (e.g. int, float, bytes, bits, utf8, utf16, utf32, or utf*_codepoint). A segment can have exactly one type; the second type option triggers this error at the location of the offending option.
Solutions
- Remove the redundant type specifier, keeping only one type per segment
- If you intended a sizing option, use 'size:n' or 'unit:n' instead of a second type
- Merge intent into a single type that matches the data (e.g. choose bytes vs utf8, not both)
Example fix
// before let assert <<header:32:float>> = data // after let assert <<header:float>> = data
Defensive patterns
Strategy: validation
Validate before calling
// Count type options before writing a segment: exactly one of
// int | float | bytes | bits | utf8 | utf16 | utf32 | utf8_codepoint | utf16_codepoint | utf32_codepoint
fn count_type_options(spec: String) -> Int {
["int", "float", "bytes", "bits", "utf8", "utf16", "utf32"]
|> list.filter(fn(t) { string.contains(spec, ":" <> t) })
|> list.length
} Prevention
- One type option per segment — always verify after edits
- Remember size/unit are modifiers, not types; use them instead of adding a second type
- Let the compiler/linter read the segment aloud: type, then size, then unit, then signedness, then endianness
When it happens
Trigger: Writing two type specifiers on one segment, such as <<x:int:float>> or <<data:bytes:utf8>>, in either a bit array expression or a pattern.
Common situations: Typos where the author meant a size or unit option but wrote a second type; copy-paste edits that left a stale type option behind; misunderstanding that ':utf8' is a type, not a modifier.
Related errors
- ErrorType::ConflictingEndiannessOptions
- ErrorType::ConflictingSignednessOptions
- ErrorType::ConflictingSizeOptions
- ErrorType::ConflictingUnitOptions
- ErrorType::ConstantSizeNotPositive
AI-assisted analysis of gleam-lang/gleam@15b07c7830 (2026-09-14).
Data as JSON: /api/errors/94389fab5c18266a.
Report an issue: GitHub.
Appendix: source
Thrown at compiler-core/src/bit_array.rs:135
target,
option: UnsupportedOption::UtfCodepointPattern,
},
option.location(),
);
}
Bytes { .. }
| Int { .. }
| Float { .. }
| Bits { .. }
| Utf8 { .. }
| Utf16 { .. }
| Utf32 { .. }
| Utf8Codepoint { .. }
| Utf16Codepoint { .. }
| Utf32Codepoint { .. } => {
if let Some(previous) = categories.type_ {
return err(
ErrorType::ConflictingTypeOptions {
existing_type: previous.label(),
},
option.location(),
);
} else {
categories.type_ = Some(option);
}
}
Signed { .. } | Unsigned { .. } => {
if let Some(previous) = categories.signed {
return err(
ErrorType::ConflictingSignednessOptions {
existing_signed: previous.label(),
},
option.location(),
);View on GitHub (pinned to 15b07c7830)