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

TreatWarningsAsErrors does not treat warnings as errors #2521

Open
Wallace-Kelly opened this issue Aug 27, 2021 · 3 comments
Open

TreatWarningsAsErrors does not treat warnings as errors #2521

Wallace-Kelly opened this issue Aug 27, 2021 · 3 comments

Comments

@Wallace-Kelly
Copy link

Description

When the property <TreatWarningsAsErrors>true</TreatWarningsAsErrors> is included in the fsproj file, the Fable compiler still issues warnings instead of errors.

Repro code

Test.fsproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="Library.fs" />
  </ItemGroup>

</Project>

Library.fs

module WarnAsErrorTest

type Message = Load | Save | Exit

let message =
    function
    | Load -> printfn "Loading"
    | Save -> printfn "Saving"

Expected and actual results

Expected

Running dotnet fable should print an error message.

Actual

Running dotnet build does print an error message.

Running dotnet fable does not print an error message.

Related information

  • Fable version: dotnet fable --version : 3.2.12
  • Operating system: Windows
@inosik
Copy link
Contributor

inosik commented Aug 28, 2021

WarningsAsErrors doesn't seem to work anymore either.

@inosik
Copy link
Contributor

inosik commented Aug 28, 2021

Treating warnings as errors was disabled for referenced projects, see #2288. But looks like this affects the actual project as well.

alfonsogarciacaro added a commit that referenced this issue Sep 6, 2021
@alfonsogarciacaro
Copy link
Member

I've sent #2527 to fix this. This ignores TreatWarningsAsErrors if set in a project reference (or package) and only takes it into account if set into the main project. However the tricky part is Fable collects all sources (including project references and package sources) into a single project, so setting TreatWarningsAsErrors in the main project will turn warnings into errors in project references and packages as well, which is likely breaking. In fact, Fable currently ignores warnings from packages.

Not sure what's the best solution here, Fable could ignore errors from packages too, but this will likely produce false negatives 🤔

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

No branches or pull requests

3 participants