dotnet / dotnet/fsharp

#nowarn in the editor does not ignore warning if --warnaserrors flag is set, but compiler does

Open
#9,796 0 comments 1 reaction 0 assignees View on GitHub
Area-Compiler-Options Bug good first issue help wanted Impact-Low
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

(edited, it is not related to `--warnon`, but to `--warnaserrors`)

If you have `--warnaserror:xxxx`, and on file-level you disable that same warning, you still see the errors in that file, while the compiler succeeds. This is confusing.

## Repro steps (1)

1. Add "25" to the _Warnings as errors_:
![image](https://user-images.githubusercontent.com/16015770/88480488-70831f80-cf56-11ea-8883-25fac9bacf88.png)
2. Add `#nowarn "25"` to a source file.
2. Write code that triggers this warning:
![image](https://user-images.githubusercontent.com/16015770/88480575-f737fc80-cf56-11ea-8e19-e1a0f5b2b50e.png)

## Repro steps (2)

1. Add `warnon:1182` in project settings:
![image](https://user-images.githubusercontent.com/16015770/88479889-c05fe780-cf52-11ea-9e88-66cf28d0396c.png)
2. Add `FS1182` to the "warnings as errors":
![image](https://user-images.githubusercontent.com/16015770/88480085-1e40ff00-cf54-11ea-81e0-1a313eb9d0f1.png)
3. Inside a source file, add `#nowarn:1182` at the top
4. Have a line with an unused variable

![image](https://user-images.githubusercontent.com/16015770/88479963-3f552000-cf53-11ea-98de-22dee4a0a8ad.png)

**Expected behavior**

Inside a file, the editor should consider the `#nowarn` directives.

**Actual behavior**

Apparently, the editor highlighting tooling is aware of the `--warnaserror` compiler option, but not of the `#nowarn` directive in the file, and shows the error, while `fsc` doesn't show an error.

* It shouldn't show the red squiggles
* It should (probably) still show the "unused" warning in the mouseover
* It should keep the ident greyed out

**Known workarounds**

Don't use these options, or fix your errors. But as seen in #9795, that's not always possible.

**Related information**

* It doesn't matter whether you use the UI setting, or add `--warnaserror:XXXX` to the addition fsc options

----

Not really related anymore, but FYI, since 1182 is a "special" warning that does not get triggered on any warning level, unless you add the `--warnon:XXXX` to the options.

In this reaction, back in 2015 (!) (https://github.com/dotnet/fsharp/issues/422#issuecomment-99961730), @dsyme mentions that opt-in for FS1182 was deliberate. It was done before moving to github, so I cannot find the decision/discussion or changes.

> Yes, I do recall this, it's good to have it recorded (and yes, this was one of the reasons /warn:1182 was made opt-in)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.