gleam-lang/gleam · error · ErrorType
ErrorType::ConflictingSizeOptions
Error message
ErrorType::ConflictingSizeOptions
What it means
ErrorType::ConflictingSizeOptions is raised when a bit array segment declares the size option more than once (e.g. two 'size:n' options on one segment). Each segment may have at most one size specification.
Solutions
- Keep only one size option per segment
- If you meant a byte-vs-bit unit distinction, use the unit option alongside a single size
- Recompute the intended size and replace, don't append, the existing size option
Example fix
// before <<id:int-size(4)-size(8)>> // after <<id:int-size(8)>>
Defensive patterns
Strategy: validation
Validate before calling
// At most one `size:` option per segment
fn size_option_count(spec: String) -> Int {
string.split(spec, "size:") |> list.length |> int.subtract(1)
} Prevention
- Edit sizes in place; never add a second size option
- Remember the total segment size is size * unit — adjust one of them, not both by stacking
- Search segments for 'size' before merging branches that both touch sizing
When it happens
Trigger: Writing <<x:int-size(8)-size(16)>> or similar duplicated size options; also combining size with a variable-sized option in ways that set categories.size twice.
Common situations: Merging edits that both added a size; copy-paste from another segment that already had a size; adjusting a size and leaving the old option in place.
Related errors
- ErrorType::ConflictingEndiannessOptions
- ErrorType::ConflictingSignednessOptions
- ErrorType::ConflictingUnitOptions
- This is an extra type specifier
- ErrorType::ConstantSizeNotPositive
AI-assisted analysis of gleam-lang/gleam@15b07c7830 (2026-09-14).
Data as JSON: /api/errors/c69d78402d33b4a4.
Report an issue: GitHub.
Appendix: source
Thrown at compiler-core/src/bit_array.rs:184
);
}
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);
}
}
Unit { .. } => {
if categories.unit.is_some() {
return err(ErrorType::ConflictingUnitOptions, option.location());
} else {
categories.unit = Some(option);
}
}
}
}
// Some options are not allowed in value mode
if mode == TypeOptionsMode::Expression {
match categories {View on GitHub (pinned to 15b07c7830)