fsharp
fsharp copied to clipboard
Using `TailCall` diagnostic attribute on non tailcall rec function does not generate warning on Visual Studio Error List pane
Please provide a succinct description of the issue.
Repro steps
Steps required to reproduce the problem:
- Use this code on any .fs file and compile it:
[<TailCall>]
let rec private sumListTailRecHelperWithTailcallDiagnostic accumulator xs =
match xs with
| [] -> accumulator
| y::ys -> sumListTailRecHelper (accumulator+y) ys
/// This example computes the sum of a list of integers using recursion.
[<TailCall>]
let rec sumList xs =
match xs with
| [] -> 0
| y::ys -> y + sumList ys
- Watch the output pane for Build and the Error List pane.
Is this intentional? As usually compiler warning is also always shown on Error List pane.
Expected behavior
Both Error List pane and the Output pane of Build should show the warning of using TailCall attribute on non tailcall rec function.
Actual behavior
Only Built output show compiler warning, whereas the Error List do not show the warning:
Known workarounds
As far as I know, none. I have tried to clear the compiler output folder, and compile again using clean rebuild.
Related information
Provide any related information (optional):
- Operating system: Windows 11 23H2
- .NET Runtime kind (.NET Core, .NET Framework, Mono): .NET 8.0
- Editing Tools (e.g. Visual Studio Version, Visual Studio): VS 2022 v17.8.1 (also reproducible on 17.8.3)
I'm fairly certain we don't run it in IDE during checks since it's quite expensive.
@vzarytovskii
I'm fairly certain we don't run it in IDE during checks since it's quite expensive.
Pardon, do you mean that this bug is by design? I mean, it should be kept as is without displaying any warning status on VS 2022 Error List pane?
@vzarytovskii
I'm fairly certain we don't run it in IDE during checks since it's quite expensive.
Pardon, do you mean that this bug is by design? I mean, it should be kept as is without displaying any warning status on VS 2022 Error List pane?
Yeah, this is not something we run as part of ide at the moment
@vzarytovskii
Feel free to CMIIW, but based on this blog: https://devblogs.microsoft.com/dotnet/announcing-fsharp-8/ It says there should be a warning when build. Normally, those warning messages when building the project should be shown in the IDE, right? Otherwise I think the blog should clearly mention that those warning messages of TailCall will only be shown in Output pane.
But then, those messages in Output pane will be scrolled when there are too many important warnings come after it, particularly when the solution contains many projects. Having these warning messages not shown by default will be overlooked since this means we have to crawl manually in the Output pane to search for this specific warning, instead of directly look at the Error List pane as we used to do.
Pardon, having the experience of this warning message is not shown on the Error List is a bit strange and non intuitive, though. Then the current F# docs on MS Learn should also clearly state that this warning is not displayed on the Error List. including the blog post above should be updated too.
Let's say we should leave this as is, but consider this scenario when coding in VS 2022 IDE: then we will have to get used to be aware that there are some F# compilation warning messages that aren't displayed on the Error List then look at the logs of Output pane of the Build. This is still unpleasant during development using VS 2022 IDE, though.
CMIIW, I'm open for discussions and the explanation especially why it is expensive to display on IDE. 🙂
@vzarytovskii
Feel free to CMIIW, but based on this blog:
https://devblogs.microsoft.com/dotnet/announcing-fsharp-8/
It says there should be a warning when build. Normally, those warning messages when building the project should be shown in the IDE, right? Otherwise I think the blog should clearly mention that those warning messages of TailCall will only be shown in Output pane.
But then, those messages in Output pane will be scrolled when there are too many important warnings come after it, particularly when the solution contains many projects. Having these warning messages not shown by default will be overlooked since this means we have to crawl manually in the Output pane to search for this specific warning, instead of directly look at the Error List pane as we used to do.
Pardon, having the experience of this warning message is not shown on the Error List is a bit strange and non intuitive, though. Then the current F# docs on MS Learn should also clearly state that this warning is not displayed on the Error List. including the blog post above should be updated too.
Let's say we should leave this as is, but consider this scenario when coding in VS 2022 IDE: then we will have to get used to be aware that there are some F# compilation warning messages that aren't displayed on the Error List then look at the logs of Output pane of the Build. This is still unpleasant during development using VS 2022 IDE, though.
CMIIW, I'm open for discussions and the explanation especially why it is expensive to display on IDE. 🙂
Yeah it's warning on build, not during the check in IDE, since it requires much more heavy analysis than just typechecking, and unfortunately we don't yet have a good mechanism of requesting post-inference checks asynchronoussly and on background.
We hope to solve it with analyzers on near future.
@vzarytovskii
Just a quick suggestion: could we display the warning on Error List every time Build/Rebuild is executed when we are using VS 2022 IDE, therefore we still could have better experience when seeing TailCall warnings shown even after running full Build/Rebuild.
I think this would be great, because we don't have to display warning every time the background compile runs, only when we explicitly do Rebuild/Build projects/solutions. What do you think?
@vzarytovskii
Just a quick suggestion: could we display the warning on Error List every time Build/Rebuild is executed when we are using VS 2022 IDE, therefore we still could have better experience when seeing TailCall warnings shown even after running full Build/Rebuild.
I think this would be great, because we don't have to display warning every time the background compile runs, only when we explicitly do Rebuild/Build projects/solutions. What do you think?
We probably can do that, we will need to somehow show MSBuild diagnostics too (which is not happening now if they're from compiler (?)).
@vzarytovskii
We probably can do that, we will need to somehow show MSBuild diagnostics too (which is not happening now if they're from compiler (?)).
Thanks for considering my proposal! Is there anything I could help? Maybe giving a pointer where to show warnings/error after manually executing Build?Rebuild? If I know where to start to look and also if it's trivial, I would like to help by submitting a PR to enable showing warnings from manual Build/Rebuild 🙂
@vzarytovskii
We probably can do that, we will need to somehow show MSBuild diagnostics too (which is not happening now if they're from compiler (?)).
Thanks for considering my proposal! Is there anything I could help? Maybe giving a pointer where to show warnings/error after manually executing Build?Rebuild?
If I know where to start to look and also if it's trivial, I would like to help by submitting a PR to enable showing warnings from manual Build/Rebuild 🙂
I'm not entirely sure where to start now. The repro is quite straightforward, we'll triage it once everyone is back in the new year. That's for brining it to our attention!
@dawedawe FYI
@eriawan Checking this attribute happens in optimizer, and that's not run when in Debug configuration. You could add a --optimize+
flag to you Debug configuration if you want to see this warning. Although then the debugging experience will be degraded.
We might want to add this check to an analyzer when available.