{"record":{"id":"2f8f2fcd2a51d7c7","repo":"gleam-lang/gleam","slug":"errortype-conflictingendiannessoptions-existing-endianness","errorCode":null,"errorMessage":"ErrorType::ConflictingEndiannessOptions { existing_endianness: previous.label() }","messagePattern":"ErrorType::ConflictingEndiannessOptions (.+?)","errorType":"validation","errorClass":"ErrorType","httpStatus":null,"severity":"error","filePath":"compiler-core/src/bit_array.rs","lineNumber":171,"sourceCode":"                    );\n                } else {\n                    categories.signed = Some(option);\n                }\n            }\n\n            Native { .. } if target == Target::JavaScript => {\n                return err(\n                    ErrorType::OptionNotSupportedForTarget {\n                        target,\n                        option: UnsupportedOption::NativeEndianness,\n                    },\n                    option.location(),\n                );\n            }\n\n            Big { .. } | Little { .. } | Native { .. } => {\n                if let Some(previous) = categories.endian {\n                    return err(\n                        ErrorType::ConflictingEndiannessOptions {\n                            existing_endianness: previous.label(),\n                        },\n                        option.location(),\n                    );\n                } else {\n                    categories.endian = Some(option);\n                }\n            }\n\n            Size { .. } => {\n                if categories.size.is_some() {\n                    return err(ErrorType::ConflictingSizeOptions, option.location());\n                } else {\n                    categories.size = Some(option);\n                }\n            }\n","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/gleam-lang/gleam/blob/15b07c783065c92bb016b1b74ed0995a5259850f/compiler-core/src/bit_array.rs#L153-L189","documentation":"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.","triggerScenarios":"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.","commonSituations":"Incremental edits switching endianness without removing the old option; copy-pasted option chains; misunderstanding that options replace rather than accumulate.","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"],"exampleFix":"// before\n<<payload:bits-size(16)-little-big>>\n// after\n<<payload:bits-size(16)-little>>","handlingStrategy":"validation","validationCode":"// At most one of big | little | native per segment\nfn endianness_option_count(spec: String) -> Int {\n  [\"-big\", \"-little\", \"-native\"]\n  |> list.filter(fn(e) { string.contains(spec, e) })\n  |> list.length\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["gleam","bit-array","conflicting-options","endianness"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"15b07c783065c92bb016b1b74ed0995a5259850f","analyzedAt":"2026-09-14T11:14:59.388Z","contentChangedAt":"2026-09-14T11:14:59.388Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}