Some errors are not reported if any of previous files contain errors
Consider a project consisting of two files:
module AbstractBaseClass.File1
a
module AbstractBaseClass.File2
type AbstractBaseClass() =
abstract P: int
There's an error expected for the type declaration:
However, it's missing because of the undefined a error in the previous file. Commenting a out fixes the issue.
It seems it's a relatively recent regression, as I don't recall seeing this behavior previously.
If this is not Transparent Compiler, then I suspect this one #16576.
If this is not Transparent Compiler, then I suspect this one #16576.
Yeah, looks likely, I can bisect it once back to normal internet
Hmm, after investigating this for a bit, it seems to be on purpose...?
The diagnostics come from here: https://github.com/dotnet/fsharp/blob/0f520bce120bb2561f67e467646f4abbdb89d60c/src/Compiler/Checking/CheckDeclarations.fs#L5723-L5729
Explicitly having conditionallySuppressErrorReporting (checkForErrors()) where checkForErrors is A function to help us stop reporting cascading errors
https://github.com/dotnet/fsharp/blob/0f520bce120bb2561f67e467646f4abbdb89d60c/src/Compiler/Checking/CheckDeclarations.fs#L5650-L5651
And we put diagnostics collected from previously checked files there. https://github.com/dotnet/fsharp/blob/0f520bce120bb2561f67e467646f4abbdb89d60c/src/Compiler/Service/FSharpCheckerResults.fs#L2926-L2927
All of this seems to have been there for a while.
I am not sure what the purpose of this is: https://github.com/dotnet/fsharp/blob/0f520bce120bb2561f67e467646f4abbdb89d60c/src/Compiler/Service/FSharpCheckerResults.fs#L2912-L2915
Or what "background diagnostics" are supposed to be. We put the previous files' errors there now - maybe that's just wrong?
I think previously this would only affect the current file, i.e. it wouldn't affect showing errors in other files.
Yeah that would make sense.
If I remove playing back background diagnostics, only this test fails: https://github.com/dotnet/fsharp/blob/44af7c8141b70e33685fcf58d44145a9d93eb7d7/tests/service/MultiProjectAnalysisTests.fs#L950-L972
https://github.com/dotnet/fsharp/pull/16719
~Interestingly Transparent Compiler doesn't have this problem.~ Never mind, it does if the files depend on each other, which just wasn't the case in the example.