gleam-lang/gleam · error · ErrorType

ErrorType::ConflictingSignednessOptions

Error message

ErrorType::ConflictingSignednessOptions { existing_signed: previous.label() }

What it means

ErrorType::ConflictingSignednessOptions is raised when a segment declares signedness more than once, e.g. both signed and unsigned options on the same bit array segment. previous.label() reports the signedness that was already given.

Solutions

  1. Delete the duplicate signed or unsigned option, keeping one
  2. Decide the intended signedness for the segment and keep only that option
  3. If the intent differed per use, split into two segments or two variables

Example fix

// before
<<value:int:unsigned:signed>>
// after
<<value:int:unsigned>>
Defensive patterns

Strategy: validation

Validate before calling

// A segment may contain `signed` or `unsigned`, never both
fn has_conflicting_signedness(spec: String) -> Bool {
  string.contains(spec, "signed") && string.contains(spec, "unsigned")
}

Prevention

When it happens

Trigger: A segment like <<n:signed-unsigned-size(8)>> or <<n:int:unsigned:signed>> in an expression or pattern; type_options detects categories.signed already set when a second Signed/Unsigned option appears.

Common situations: Hand-editing segment options and forgetting the original signedness; macro-like copy-paste of option lists; confusion between the option names signed/unsigned and the type.

Related errors


AI-assisted analysis of gleam-lang/gleam@15b07c7830 (2026-09-14). Data as JSON: /api/errors/0a79b94709ee9d29. Report an issue: GitHub.

Appendix: source

Thrown at compiler-core/src/bit_array.rs:148

            | 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(),
                    );
                } else {
                    categories.signed = Some(option);
                }
            }

            Native { .. } if target == Target::JavaScript => {
                return err(
                    ErrorType::OptionNotSupportedForTarget {
                        target,
                        option: UnsupportedOption::NativeEndianness,
                    },
                    option.location(),
                );

View on GitHub (pinned to 15b07c7830)