{"record":{"id":"62ba2612533394f0","repo":"gleam-lang/gleam","slug":"errortype-signednessusedonnonint-type-opt-label","errorCode":null,"errorMessage":"ErrorType::SignednessUsedOnNonInt { type_: opt.label() }","messagePattern":"ErrorType::SignednessUsedOnNonInt (.+?)","errorType":"validation","errorClass":"ErrorType","httpStatus":null,"severity":"error","filePath":"compiler-core/src/bit_array.rs","lineNumber":262,"sourceCode":"            ..\n        } => return err(ErrorType::InvalidEndianness, endian.location()),\n\n        _ => {}\n    }\n\n    // signed and unsigned can only be used with int types\n    match categories {\n        SegmentOptionCategories {\n            type_: None | Some(Int { .. }),\n            ..\n        } => {}\n\n        SegmentOptionCategories {\n            type_: Some(opt),\n            signed: Some(sign),\n            ..\n        } => {\n            return err(\n                ErrorType::SignednessUsedOnNonInt { type_: opt.label() },\n                sign.location(),\n            );\n        }\n\n        _ => {}\n    }\n\n    // utf8, utf16, utf32 exclude unit and size\n    match categories {\n        SegmentOptionCategories {\n            type_: Some(type_),\n            unit: Some(unit),\n            ..\n        } if is_unicode(type_) => {\n            return err(\n                ErrorType::TypeDoesNotAllowUnit {\n                    type_: type_.label(),","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/gleam-lang/gleam/blob/15b07c783065c92bb016b1b74ed0995a5259850f/compiler-core/src/bit_array.rs#L244-L280","documentation":"In Gleam bit array segments, the `signed`/`unsigned` option is only meaningful for integer-typed segments. The compiler's `type_options` in compiler-core/src/bit_array.rs rejects a segment that declares signedness when the segment's explicit type annotation is not an integer (e.g. float, utf8, bit_array). The error reports the offending type's label via `opt.label()` at the signedness option's location.","triggerScenarios":"Combining `signed`/`unsigned` with a non-integer type in a bit array segment, e.g. `<<1.5:float-signed>>` or `<<x:utf8-signed>>`, in either a bit array expression or a pattern (raised via `type_options_for_value` / `type_options_for_pattern`).","commonSituations":"Porting Erlang/Elixir bit syntax where signedness rules differ; typos attaching `:signed` to float or string segments; early confusion about which options apply to which segment types.","solutions":["Remove the `signed`/`unsigned` option from segments whose type is not an integer.","If a signed integer was intended, annotate the segment as an integer type, e.g. `<<x:int-signed>>`.","If a float or string segment was intended, keep only options valid for that type (e.g. `size`, `big`/`little`)."],"exampleFix":"// before\nlet a = <<3.14:float-signed>>\n// after\nlet a = <<3.14:float>>\n// or for a signed integer:\nlet b = <<3:int-signed>>","handlingStrategy":"validation","validationCode":"// Gleam checks this at compile time; guard at authoring time.\n// Only apply signedness to int segments:\n// let ok  = <<value:int-signed>>\n// let bad = <<value:float-signed>>\nfn signedness_allowed(type_label: String) -> Bool {\n  type_label == \"Int\"\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only combine `signed`/`unsigned` with `int` segments.","Remember each segment type (float, utf8, bytes) has its own valid option set.","Run `gleam build` often so compile-time option checks surface immediately.","Review bit syntax carefully when porting from Erlang/Elixir."],"tags":["compiler","bit-array","type-error","gleam"],"backgroundTag":"invalid-argument-value","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"}