-
Notifications
You must be signed in to change notification settings - Fork 833
Description
Byte in char form is limited to ASCII range:
> 'a';;
val it: char = 'a'
> int 'a';;
val it: int = 97
> 'a'B;;
val it: byte = 97uy
> 'ú';;
val it: char = 'ú'
> int 'ú';;
val it: int = 250
> 'ú'B;;
^^^^
stdin(17,1): error FS1157: This is not a valid byte literalSame limit for UTF16 notation:
> '\u00FA';;
val it: char = 'ú'
> '\u00FA'B;;
^^^^^^^^^
stdin(24,1): error FS1157: This is not a valid byte literalBUT: in decimal notation the value can span all of byte range:
> '\250';;
val it: char = 'ú'
> '\250'B;;
val it: byte = 250uy(numbers over 255 aren't valid: '\256'B -> error FS1157: This is not a valid byte literal)
(other char notations for byte aren't currently supported. See #15867)
Expected behavior
decimal notation and other notations should have same range limits.
Actual behavior
While char & UTF16-hex must be <128, decimal can be any byte-value (<256).
It's called ASCII byte in the docs, so the correct range is probably 0..127. (There's also a test check for error when >= 128) And the 255 boundary is then most likely a copy&paste error from 3-digit decimal char
Though I personally would prefer char byte to allow all of byte range (0..255):
- there's
\unicode notation which already signals there's "more" than just ASCII - slightly strange to have a valid char with a value inside byte range -- but invalid byte char because
>= 128 - In Byte String array values over
127are possible:> "ú\250\xFA\u00FA\U000000FA"B;; val it: byte array = [|250uy; 250uy; 250uy; 250uy; 250uy|]
Whatever is desired: I would give it a try fixing/adjusting it (together with #15867). I just need to know what range should be valid.
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