{"record":{"id":"d42159491439aa21","repo":"gleam-lang/gleam","slug":"errortype-optionnotsupportedfortarget-target-option","errorCode":null,"errorMessage":"ErrorType::OptionNotSupportedForTarget { target, option: UnsupportedOption::NativeEndianness }","messagePattern":"ErrorType::OptionNotSupportedForTarget (.+?)","errorType":"validation","errorClass":"ErrorType","httpStatus":null,"severity":"error","filePath":"compiler-core/src/bit_array.rs","lineNumber":160,"sourceCode":"                    categories.type_ = Some(option);\n                }\n            }\n\n            Signed { .. } | Unsigned { .. } => {\n                if let Some(previous) = categories.signed {\n                    return err(\n                        ErrorType::ConflictingSignednessOptions {\n                            existing_signed: previous.label(),\n                        },\n                        option.location(),\n                    );\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);","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/gleam-lang/gleam/blob/15b07c783065c92bb016b1b74ed0995a5259850f/compiler-core/src/bit_array.rs#L142-L178","documentation":"ErrorType::OptionNotSupportedForTarget with UnsupportedOption::NativeEndianness: the native endianness option (native) on a bit array segment is not supported when compiling to JavaScript, because JS has no native byte-order control.","triggerScenarios":"Any bit array segment written with the 'native' endianness option (e.g. <<x:int-native>>) in code compiled for Target::JavaScript, whether in an expression or a pattern.","commonSituations":"Shared code written for Erlang that uses native byte order, then compiled for the browser/Node; protocol code that relied on host endianness for speed.","solutions":["Replace native with an explicit big or little endianness option","Pick the byte order your wire format actually requires (usually big) instead of host-native","Gate native-endianness code behind a module used only on the Erlang target"],"exampleFix":"// before\n<<num:int-size(32)-native>>\n// after\n<<num:int-size(32)-big>>","handlingStrategy":"validation","validationCode":"// Avoid `native` on the JavaScript target\nfn native_endianness_ok(target: String) -> Bool {\n  target != \"javascript\"\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always spell out big or little explicitly; reserve native for Erlang-only code","Wire formats should define byte order explicitly rather than relying on host endianness","Build for all targets in CI to surface target-specific rejections"],"tags":["gleam","bit-array","javascript-target","endianness"],"backgroundTag":"unsupported-operation","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"}