{"record":{"id":"bce54c12aecafef5","repo":"gleam-lang/gleam","slug":"errortype-optionnotallowedinvalue","errorCode":null,"errorMessage":"ErrorType::OptionNotAllowedInValue","messagePattern":"ErrorType::OptionNotAllowedInValue","errorType":"validation","errorClass":"ErrorType","httpStatus":null,"severity":"error","filePath":"compiler-core/src/bit_array.rs","lineNumber":209,"sourceCode":"                if categories.unit.is_some() {\n                    return err(ErrorType::ConflictingUnitOptions, option.location());\n                } else {\n                    categories.unit = Some(option);\n                }\n            }\n        }\n    }\n\n    // Some options are not allowed in value mode\n    if mode == TypeOptionsMode::Expression {\n        match categories {\n            SegmentOptionCategories {\n                signed: Some(opt), ..\n            }\n            | SegmentOptionCategories {\n                type_: Some(opt @ Bytes { .. }),\n                ..\n            } => return err(ErrorType::OptionNotAllowedInValue, opt.location()),\n            _ => (),\n        }\n    }\n\n    // All but the last segment in a pattern must have an exact size\n    if must_have_size\n        && let SegmentOptionCategories {\n            type_: Some(opt @ (Bytes { .. } | Bits { .. })),\n            size: None,\n            ..\n        } = categories\n    {\n        return err(ErrorType::SegmentMustHaveSize, opt.location());\n    }\n\n    // Endianness is only valid for int, utf16, utf16_codepoint, utf32,\n    // utf32_codepoint and float\n    match categories {","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/gleam-lang/gleam/blob/15b07c783065c92bb016b1b74ed0995a5259850f/compiler-core/src/bit_array.rs#L191-L227","documentation":"ErrorType::OptionNotAllowedInValue: after collecting segment options, type_options rejects options that are only legal in patterns when the segment appears in a bit array VALUE expression. Specifically a signed/unsigned option, or a bare bytes type option in this position, is not permitted in a value.","triggerScenarios":"Constructing a bit array value with a segment carrying signed/unsigned (e.g. <<x:int-signed>>) or a Bytes option that the value-mode post-check disallows (categories.signed set, or type_ is Bytes in value mode).","commonSituations":"Assuming signedness is an encoding concern in value construction (it only matters for pattern matching); copying a pattern segment verbatim into an expression.","solutions":["Remove the signed/unsigned option from value expressions; signedness only affects matching","Use an explicit sized int/float type in the value instead of the disallowed option","If the code was intended as a pattern, move it into a case/let-assert pattern position"],"exampleFix":"// before (value)\nlet x = <<n:int-signed>>\n// after\nlet x = <<n:int>>","handlingStrategy":"validation","validationCode":"// signedness (and bare bytes in this position) only belongs in patterns, not values\nfn is_value_with_signedness(segment_spec: String, in_pattern: Bool) -> Bool {\n  !in_pattern\n  && { string.contains(segment_spec, \"signed\") || string.contains(segment_spec, \"unsigned\") }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat signed/unsigned as pattern-only modifiers","Copy pattern segments into expressions only after stripping match-specific options","When a value segment needs interpretation, decode it in code rather than via pattern options"],"tags":["gleam","bit-array","value-expression"],"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"}