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

--langversion parser is culture-dependent #7757

Closed
ForNeVeR opened this issue Oct 22, 2019 · 5 comments · Fixed by #7895
Closed

--langversion parser is culture-dependent #7757

ForNeVeR opened this issue Oct 22, 2019 · 5 comments · Fixed by #7895
Labels
Milestone

Comments

@ForNeVeR
Copy link
Contributor

ForNeVeR commented Oct 22, 2019

Repro steps

  1. Create a new F# project: dotnet new console -lang F#

  2. Add <LangVersion> to the project:

    <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>netcoreapp3.0</TargetFramework>
        <LangVersion>4.7</LangVersion>
      </PropertyGroup>
      <ItemGroup>
        <Compile Include="Program.fs" />
      </ItemGroup>
    </Project>
  3. Now, try to build the project:

    $ dotnet build
    Microsoft (R) Build Engine version 16.3.0+0f4c62fea for .NET Core
    Copyright (C) Microsoft Corporation. All rights reserved.
    
      Restore completed in 26,26 ms for T:\Temp\fsproj\fsproj.fsproj.
    FSC : error FS0246: Unrecognized value '4.7' for --langversion use --langversion:? for complete list [T:\Temp\fsproj\fsproj.fsproj]
    

It seems to be linked with my machine's Russian culture (which uses decimal comma instead of decimal point).

Known workarounds

Use <LangVersion>4,7</LangVersion> (yes, with a comma!) — but please never do that, it's totally not portable

Additional info

It's not a dotnet build issue, the same happens if I directly invoke dotnet fsc.exe:

$ cd "C:\Program Files\dotnet\sdk\3.0.100\FSharp"
$ dotnet fsc.exe --langversion:4.7

error FS0246: Unrecognized value '4.7' for --langversion use --langversion:? for complete list

$ dotnet fsc.exe --langversion:4,7
Microsoft (R) F# Compiler version 10.6.0.0 for F# 4.7
Copyright (c) Microsoft Corporation. All Rights Reserved.

error FS0207: No inputs specified

Related information

$ dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.0.100
 Commit:    04339c3a26

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18362
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100\

Host (useful for support):
  Version: 3.0.0
  Commit:  7d57652f33
@ForNeVeR
Copy link
Contributor Author

ForNeVeR commented Oct 22, 2019

Notably, the following works, too:

$ dotnet fsc.exe --langversion:4,700000000000000000000000000000000000000001

Because 4,700000000000000000000000000000000000000001 is exactly the same double as 4,7.

I don't think it's a good idea to parse the version numbers as floating point values.

@abelbraaksma
Copy link
Contributor

abelbraaksma commented Oct 22, 2019

Versions should clearly not be a numeric value. I believe Microsoft adopted Semver, so possible values can include multiple dots and a build string (even though that may not be supported right now by LangVersion, several versions strings used with F# in the past cannot be processed as decimal, so it should be agnostic to that). In other words, this should be a string value and not parsed into a decimal.

BTW, the same issue happens in the Netherlands and Germany, and I'm sure there are others.

@cartermp
Copy link
Contributor

This should be easy to resolve, though semver doesn't apply to language versioning.

@cartermp cartermp added this to the Backlog milestone Oct 23, 2019
@jmarolf
Copy link

jmarolf commented Oct 23, 2019

I assume that you would want to use Version.Parse for this.

@milbrandt
Copy link
Contributor

As one can think off, this happens also with F# in Visual Studio 2019 (16.3.9) and German Windows. Obviously <LangVersion>4,6</LangVersion> should not be committed to any Github repo - the CI build will fail in all likelihood.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants