The compiler version that ships with VS2019 v16.5.1 doesn't recognize number literals such as 1e-6f.
error FS1153: Invalid floating point number
it works fine in v16.4 releases and in the 16.6 preview release so it probably is fixed already.
Related information
Thanks for the report @smoothdeveloper. I can't reproduce this with the .NET 5 preview compiler (should be the same bits as 16.5? Could be wrong though...). Though I did note that dotnet fsi formatting prints it a bit differently...
> 1e-6f;;
val it : float32 = 9.999999975e-07f
Tagging as needs-repro - I asked @KevinRansom and @TIHan to see if they can observe this
@cartermp @smoothdeveloper, I don't see this with 3.1.200 of the dotnet sdk, or the desktop compiler version 10.8.0.0 for F# 4.7.
It is also worth noting that no servicing changes happened for F# in 16.5.1
However, fsi:
````
C:\Users\kevinr\source\reposConsoleApp4ConsoleApp4>dotnet "C:\Program Filesdotnet\sdk\3.1.200\FSharp\fsi.exe"
Microsoft (R) F# Interactive version 10.8.0.0 for F# 4.7
Copyright (c) Microsoft Corporation. All Rights Reserved.
For help type #help;;
let a = 1e-6f;;
let a = 1e-6f;;
--------^^^^^
stdin(1,9): error FS1153: Invalid floating point number
1e-6f;;
1e-6f;;
^^^^^
stdin(2,1): error FS1153: Invalid floating point number
>
````
Okay, this is due to https://github.com/dotnet/fsharp/pull/7839/files
@smoothdeveloper as a quick workaround you can just set <LangVersion>preview</LangVersion in your affected project(s) and it should make the problem go away.
@smoothdeveloper just wanted to say that this might be a first: three Microsoft employees who contribute to the compiler codebase signed off on the change officially in its final form (with another who felt it was a great change midway through development). Additionally, there were no tests we could find for this case. So I think it's rather impressive that this managed to happen 馃槄
truly a bruh moment
@cartermp my guess is that the change looked innocuous in itself, making it easier to dismiss potential issues.
My take away is that anything touching literals, the lexer or involving compiler feature flag welcomes increased scrutiny.
I'm glad the issue was identified and already has a fix pending, props to everyone.
@smoothdeveloper, while we were looking at the issue, I still insisted it was a fine change.
Most helpful comment
@smoothdeveloper just wanted to say that this might be a first: three Microsoft employees who contribute to the compiler codebase signed off on the change officially in its final form (with another who felt it was a great change midway through development). Additionally, there were no tests we could find for this case. So I think it's rather impressive that this managed to happen 馃槄