gleam-lang/gleam · error · ErrorType
ErrorType::ConflictingEndiannessOptions
Error message
ErrorType::ConflictingEndiannessOptions { existing_endianness: previous.label() } What it means
A validation error produced by `type_options` (called from `type_options_for_value` and `type_options_for_pattern`) when checking bit array segment options. Each segment may declare endianness (Big, Little, or Native) at most once; this error fires when a second, conflicting endianness option appears after one was already given (e.g. `<<x:little:big>>`). On JavaScript the Native option is rejected separately via OptionNotSupportedForTarget; everywhere else duplicate endianness options are reported as ConflictingEndiannessOptions, naming the previously seen option's label.
Solutions
- Remove all but one endianness option from the segment
- Standardize on the byte order the format specifies (commonly big-endian)
- Search the segment option list for stray big/little/native duplicates
Example fix
// before <<payload:bits-size(16)-little-big>> // after <<payload:bits-size(16)-little>>
Defensive patterns
Strategy: validation
Validate before calling
// At most one of big | little | native per segment
fn endianness_option_count(spec: String) -> Int {
["-big", "-little", "-native"]
|> list.filter(fn(e) { string.contains(spec, e) })
|> list.length
} Prevention
- Replace, don't append, when changing a segment's endianness
- Standardize on one endianness per protocol and document it
- Audit copy-pasted option chains for duplicated endianness
When it happens
Trigger: A segment with two endianness options such as <<x:int-big-little>> or <<x:float-native-big>> in an expression or pattern; type_options detects categories.endian already populated.
Common situations: Incremental edits switching endianness without removing the old option; copy-pasted option chains; misunderstanding that options replace rather than accumulate.
Related errors
- ErrorType::ConflictingSignednessOptions
- ErrorType::ConflictingSizeOptions
- ErrorType::ConflictingUnitOptions
- ErrorType::InvalidEndianness
- ErrorType::OptionNotSupportedForTarget
AI-assisted analysis of gleam-lang/gleam@15b07c7830 (2026-09-14).
Data as JSON: /api/errors/2f8f2fcd2a51d7c7.
Report an issue: GitHub.
Appendix: source
Thrown at compiler-core/src/bit_array.rs:171
);
} else {
categories.signed = Some(option);
}
}
Native { .. } if target == Target::JavaScript => {
return err(
ErrorType::OptionNotSupportedForTarget {
target,
option: UnsupportedOption::NativeEndianness,
},
option.location(),
);
}
Big { .. } | Little { .. } | Native { .. } => {
if let Some(previous) = categories.endian {
return err(
ErrorType::ConflictingEndiannessOptions {
existing_endianness: previous.label(),
},
option.location(),
);
} else {
categories.endian = Some(option);
}
}
Size { .. } => {
if categories.size.is_some() {
return err(ErrorType::ConflictingSizeOptions, option.location());
} else {
categories.size = Some(option);
}
}
View on GitHub (pinned to 15b07c7830)