fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

Some errors are not reported if any of previous files contain errors

Open auduchinok opened this issue 1 year ago • 5 comments

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:

Screenshot 2024-02-14 at 12 26 10

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.

auduchinok avatar Feb 14 '24 11:02 auduchinok

If this is not Transparent Compiler, then I suspect this one #16576.

majocha avatar Feb 14 '24 12:02 majocha

If this is not Transparent Compiler, then I suspect this one #16576.

Yeah, looks likely, I can bisect it once back to normal internet

vzarytovskii avatar Feb 14 '24 14:02 vzarytovskii

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?

0101 avatar Feb 16 '24 19:02 0101

I think previously this would only affect the current file, i.e. it wouldn't affect showing errors in other files.

auduchinok avatar Feb 16 '24 21:02 auduchinok

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.

0101 avatar Feb 19 '24 10:02 0101