cannorin / FSharp.CommandLine

A framework for building command line application in F#
Apache License 2.0
59 stars 1 forks source link

Failed to build sample from README in F# 5, "error FS3098: 'opt' must come after a 'for' selection clause and be followed by the rest of the query." #8

Closed applejag closed 2 years ago

applejag commented 3 years ago

Description

I'm getting compile errors from the example from README.md

Repro steps

  1. Have F# 5 installed. .NET SDK 5.0 ships with it.

  2. dotnet new console -lang 'F#' -n MyCommandLineApp
  3. dotnet add MyCommandLineApp package FSharp.CommandLine
  4. Replace content of Program.fs with content from README.md (taken from commit: 5b5df21)

  5. dotnet build MyCommandLineApp

Expected behavior

Builds successfully

Actual behavior

Compile error

$ dotnet build MyCommandLineApp
Microsoft (R) Build Engine version 16.8.0+126527ff1 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored C:\Projekt\MyCommandLineApp\MyCommandLineApp.fsproj (in 785 ms).
C:\Projekt\MyCommandLineApp\Program.fs(30,5): error FS3098: 'opt' must come after a 'for' selection clause and be followed by the rest of the query. Syntax: ... opt var in collection ... [C:\Projekt\MyCommandLineApp\MyCommandLineApp.fsproj]

Build FAILED.

C:\Projekt\MyCommandLineApp\Program.fs(30,5): error FS3098: 'opt' must come after a 'for' selection clause and be followed by the rest of the query. Syntax: ... opt var in collection ... [C:\Projekt\MyCommandLineApp\MyCommandLineApp.fsproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:07.29

Known workarounds

Use F# 4.7 or below.

Either by adding this to the .fsproj:

    <PropertyGroup>
      <OutputType>Exe</OutputType>
      <TargetFramework>net5.0</TargetFramework>
+     <LangVersion>4.7</LangVersion>
    </PropertyGroup>

Or by creating the app with the --langVersion argument:

dotnet new console --lang 'F#' -n MyCommandLineApp --langVersion 4.7

Related information

cannorin commented 3 years ago

I consider this a regression and will open an issue on https://github.com/dotnet/fsharp .

cannorin commented 3 years ago

^ opened an issue.

cannorin commented 3 years ago

It is now fixed, so we will wait for the next release of F# then close this issue.