Skip to content

Commit

Permalink
Improve numeric literal error - fixes #1129
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed May 3, 2016
1 parent ce687a4 commit 517f26c
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/fsharp/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ lexUnexpectedChar,"Unexpected character '%s'"
1153,lexInvalidFloat,"Invalid floating point number"
1154,lexOusideDecimal,"This number is outside the allowable range for decimal literals"
1155,lexOusideThirtyTwoBitFloat,"This number is outside the allowable range for 32-bit floats"
1156,lexInvalidNumericLiteral,"This is not a valid numeric literal. Sample formats include 4, 0x4, 0b0100, 4L, 4UL, 4u, 4s, 4us, 4y, 4uy, 4.0, 4.0f, 4I."
1156,lexInvalidNumericLiteral,"This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0b0001 (int), 1u (uint32), 1L (int64), 1UL (uint64), 1s (int16), 1y (sbyte), 1ui (byte), 1.0 (float), 1.0f (float32), 1.0m (decimal), 1I (BigInteger)."
1157,lexInvalidByteLiteral,"This is not a valid byte literal"
1158,lexInvalidCharLiteral,"This is not a valid character literal"
1159,lexThisUnicodeOnlyInStringLiterals,"This Unicode encoding is only valid in string literals"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#light

// Test invalid identifiers
//<Expects id="FS1156" status="error">This is not a valid numeric literal. Sample formats include 4, 0x4, 0b0100, 4L, 4UL, 4u, 4s</Expects>
//<Expects id="FS1156" status="error">This is not a valid numeric literal. Valid numeric literals include</Expects>

let 0leaderingzero = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ open System

// Test setting the 'line', which we validate by checking the line/col span in errors

//<Expects id="FS1156" span="(1006,9)" status="error">This is not a valid numeric literal\. Sample formats include 4, 0x4, 0b0100, 4L, 4UL, 4u, 4s, 4us, 4y, 4uy, 4\.0, 4\.0f, 4I</Expects>
//<Expects id="FS1156" span="(1006,9)" status="error">This is not a valid numeric literal. Valid numeric literals include</Expects>

# 1000 "Line01.fs"
// 1000
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// #Regression #Conformance #LexicalAnalysis #Constants
// Number type specifier
// IEEE32/IEEE64 - lF is illegal
//<Expects status="error" span="(6,9-6,14)" id="FS1156">This is not a valid numeric literal\. Sample formats include 4, 0x4, 0b0100, 4L, 4UL, 4u, 4s, 4us, 4y, 4uy, 4\.0, 4\.0f, 4I\.$</Expects>
//<Expects status="error" span="(6,9-6,14)" id="FS1156">This is not a valid numeric literal. Valid numeric literals include</Expects>

let x = 0X5lF

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// #Conformance #ObjectOrientedTypes #Classes #MethodsAndProperties
// <Expects status="error" id="FS1156" span="(4,16-4,18)">This is not a valid numeric literal\. Sample formats include 4, 0x4, 0b0100, 4L, 4UL, 4u, 4s, 4us, 4y, 4uy, 4\.0, 4\.0f, 4I\.</Expects>
// <Expects status="error" id="FS1156" span="(4,16-4,18)">This is not a valid numeric literal. Valid numeric literals include</Expects>
type T() =
member val 1P = [] with get,set

Expand Down
6 changes: 6 additions & 0 deletions tests/fsharpqa/Source/Warnings/WrongNumericLiteral.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// #Warnings
//<Expects status="Error" span="(4,11)" id="FS1156">This is not a valid numeric literal. Valid numeric literals include</Expects>

let foo = 1up

exit 0
1 change: 1 addition & 0 deletions tests/fsharpqa/Source/Warnings/env.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SOURCE=WrongNumericLiteral.fs # WrongNumericLiteral.fs
1 change: 1 addition & 0 deletions tests/fsharpqa/Source/test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ Misc01 Libraries\Core\NativeInterop\stackalloc
Misc01 Libraries\Core\Operators
Misc01 Libraries\Core\Reflection
Misc01 Libraries\Core\Unchecked
Misc01 Warnings

Misc02 Libraries\Portable
Misc02 Misc
Expand Down

0 comments on commit 517f26c

Please sign in to comment.