-
Notifications
You must be signed in to change notification settings - Fork 833
Description
A byte can be represented as integer number (97uy and its Hex/Oct/Bin formats) -- but also as char ('a'B).
Besides normal char representation ('a'), Char supports several other formats: 3-digit decimal ('\097'), 2-digit hexadecimal ('\x61'), 4-digit hexadecimal ('\u0061', UTF16), and 8-digit hexadecimal ('\U00000061', UTF32).
It would make sense for byte to support the same representations. And it does support some -- but not 2-digit and 8-digit hexadecimal:
[
'a'B
'\097'B
'\x61'B
// ^^^^^^ This value is not a function and cannot be applied.
'\u0061'B
'\U00000061'B
// ^^^^^^^^^^^^ This value is not a function and cannot be applied.
]Expected behavior
Byte supports same notations as normal char.
Actual behavior
Byte fails for 2-digit (\x) and 8-digit (\U) hex formats -- but works with other formats (including 4-digit hex (\u)).
Known workarounds
Use another format. It's quite trivial to change \x & \U to \u (4-digits) as byte doesn't support large values.
Note: \x & \U are both supported in byte string array:
> "a\097\x61\u0061\U00000061"B;;
val it: byte array = [|97uy; 97uy; 97uy; 97uy; 97uy|]Unless not handling \x & \U is desired behaviour (which I don't think because: a) why shouldn't it? and b) it's supported in byte string array), I would attempt to fix it (I think should just be slight adjustment to lexer by copying from char, adding range check and then some tests)
Related information
- Operating system: Windows 11 x64
dotnet --version:7.0.307,8.0.100-preview.7.23376.3
Metadata
Metadata
Assignees
Labels
Type
Projects
Status