Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS 16.5.1 causes FS1153 Invalid floating point number #8802

Closed
smoothdeveloper opened this issue Mar 26, 2020 · 9 comments · Fixed by #8827
Closed

VS 16.5.1 causes FS1153 Invalid floating point number #8802

smoothdeveloper opened this issue Mar 26, 2020 · 9 comments · Fixed by #8827
Milestone

Comments

@smoothdeveloper
Copy link
Contributor

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

  • VS2019 v16.5.1
@cartermp
Copy link
Contributor

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

@cartermp
Copy link
Contributor

Tagging as needs-repro - I asked @KevinRansom and @TIHan to see if they can observe this

@KevinRansom
Copy link
Member

@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

@KevinRansom
Copy link
Member

However, fsi:

C:\Users\kevinr\source\repos\ConsoleApp4\ConsoleApp4>dotnet "C:\Program Files\dotnet\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

>

@cartermp
Copy link
Contributor

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.

KevinRansom added a commit to KevinRansom/fsharp that referenced this issue Mar 28, 2020
KevinRansom added a commit to KevinRansom/fsharp that referenced this issue Mar 28, 2020
KevinRansom added a commit to KevinRansom/fsharp that referenced this issue Mar 28, 2020
@cartermp
Copy link
Contributor

@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 😅

@Happypig375
Copy link
Member

truly a bruh moment

@smoothdeveloper
Copy link
Contributor Author

@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.

@KevinRansom
Copy link
Member

@smoothdeveloper, while we were looking at the issue, I still insisted it was a fine change.

KevinRansom added a commit that referenced this issue Mar 30, 2020
KevinRansom added a commit to KevinRansom/fsharp that referenced this issue Mar 30, 2020
baronfel pushed a commit to baronfel/FSharp.Compiler.Service that referenced this issue Mar 30, 2020
KevinRansom added a commit that referenced this issue Apr 1, 2020
…ss exponential. (#8837)

* Fix #8802 (#8827)

* update mac os image
@cartermp cartermp added this to the 16.5 milestone Apr 24, 2020
nosami pushed a commit to xamarin/visualfsharp that referenced this issue Feb 23, 2021
nosami pushed a commit to xamarin/visualfsharp that referenced this issue Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants