Decimal char notation:
\DDD (where D indicates a decimal digit; range of 000 - 255; for example, \231 = "ç")
BUT: a value > 255 is accepted too -- but gets wrapped into range (% 256):
> int 'Ω';;
val it: int = 937
> "\937";;
val it: string = "©"
> int ("\937"[0]);;
val it: int = 169
> 937 % 256;;
val it: int = 169
(fable repl)
Expected behavior
Should be compiler error, like in char:
> '\937';;
^^^^^^
stdin(85,1): error FS1158: This is not a valid character literal
Actual behavior
Decimal > 255 is accepted and wrapped into byte range.
I think issue is here:
|
| trigraph |
|
{ let (buf, _fin, m, kind, args) = sargs |
|
let s = lexeme lexbuf |
|
addByteChar buf (trigraph s.[1] s.[2] s.[3]) |
|
if not skip then |
|
STRING_TEXT (LexCont.String(args.ifdefStack, args.stringNest, LexerStringStyle.SingleQuote, kind, args.interpolationDelimiterLength, m)) |
|
else |
|
singleQuoteString sargs skip lexbuf } |
There's no range check and
addByteChar then
wraps the value to byte range
I'm going to fix this together with the other char notations issues.
Related information
- Operating system: Windows 11 x64
dotnet --version: 7.0.307, 8.0.100-preview.7.23376.3
Decimal char notation:
BUT: a value
> 255is accepted too -- but gets wrapped into range (% 256):(fable repl)
Expected behavior
Should be compiler error, like in char:
Actual behavior
Decimal
> 255is accepted and wrapped into byte range.I think issue is here:
fsharp/src/Compiler/lex.fsl
Lines 1185 to 1192 in 443b3ab
There's no range check and
addByteCharthen wraps the value to byte rangeI'm going to fix this together with the other char notations issues.
Related information
dotnet --version:7.0.307,8.0.100-preview.7.23376.3