Skip to content

Let TransparentCompiler respect hash directives like #nowarn - #16667

Merged
T-Gro merged 16 commits into
dotnet:mainfrom
dawedawe:transcomp_filespecificdiagopts
Feb 12, 2024
Merged

Let TransparentCompiler respect hash directives like #nowarn#16667
T-Gro merged 16 commits into
dotnet:mainfrom
dawedawe:transcomp_filespecificdiagopts

Conversation

@dawedawe

Copy link
Copy Markdown
Contributor

Description

This fixes the issue shown in this PR

As @0101 said, we need FSharpDiagnosticOptions depending on the ParsedInput of a file. But we loose that pretty deep in the call stack. Instead of changing returns all over the place, this PR makes use of the cached FSharpParsedFile to fix this.
I hope this is an acceptable tradeoff to move the TransparentCompiler forward.

(I don't think this needs release notes)

Checklist

  • Test cases added

  • Performance benchmarks added in case of performance changes

  • Release notes entry updated:

    Please make sure to add an entry with short succinct description of the change as well as link to this pull request to the respective release notes file, if applicable.

    Release notes files:

    • If anything under src/Compiler has been changed, please make sure to make an entry in docs/release-notes/.FSharp.Compiler.Service/<version>.md, where <version> is usually "highest" one, e.g. 42.8.200
    • If language feature was added (i.e. LanguageFeatures.fsi was changed), please add it to docs/releae-notes/.Language/preview.md
    • If a change to FSharp.Core was made, please make sure to edit docs/release-notes/.FSharp.Core/<version>.md where version is "highest" one, e.g. 8.0.200.

    Information about the release notes entries format can be found in the documentation.
    Example:

    If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request.

@dawedawe
dawedawe requested a review from a team as a code ownerFebruary 7, 2024 17:06
@github-actions

github-actionsBot commented Feb 7, 2024

Copy link
Copy Markdown
Contributor

⚠️ Release notes required, but author opted out

Warning

Author opted out of release notes, check is disabled for this pull request.
cc @dotnet/fsharp-team-msft

Comment threadsrc/Compiler/Service/TransparentCompiler.fs Outdated
@0101

0101 commented Feb 7, 2024

Copy link
Copy Markdown
Contributor

If we can fix it like this then why not!

But some diagnostics refactoring might be needed eventually. We're already processing them with this config applied in ComputeTcIntermediate:

lettcConfig=
ApplyNoWarnsToTcConfig(tcConfig, parsedMainInput, Path.GetDirectoryName mainInputFileName)
// update the error handler with the modified tcConfig
errHandler.DiagnosticOptions <- tcConfig.diagnosticsOptions
letdiagnosticsLogger= errHandler.DiagnosticsLogger

Maybe it's possible to somehow make use of that.

@majocha

Copy link
Copy Markdown
Contributor

Maybe this code could work in the Finisher in processGraphNode?

@dawedawe

Copy link
Copy Markdown
ContributorAuthor

The last push is just to correct the first approach taken.
I'm looking into a better way to do this deeper in the callstack.

@nojafnojaf added the NO_RELEASE_NOTES Label for pull requests which signals, that user opted-out of providing release notes label Feb 8, 2024
@dawedawe

Copy link
Copy Markdown
ContributorAuthor

Maybe it's possible to somehow make use of that.

Thanks for the pointer. I think we are good now.

@0101

0101 commented Feb 8, 2024

Copy link
Copy Markdown
Contributor

Huh, looks like it was close 😀

Maybe this code could work in the Finisher in processGraphNode?

That would make sense if we need some prior state for the processing. But probably we're fine at this stage just with proper filtering and formatting can still happen at the end when we're creating the result.

@dawedawe

dawedawe commented Feb 8, 2024

Copy link
Copy Markdown
ContributorAuthor

Huh, looks like it was close 😀

Oh yeah, just a little shake and shuffle was needed :)

@0101

0101 commented Feb 8, 2024

Copy link
Copy Markdown
Contributor

@dawedawe do you think you could temporarily trigger the tests in CI again? To see if this had any unexpected effects.

We really need the tests auto-enabled in main, I'll try to set it up here: #16591

@dawedawe

Copy link
Copy Markdown
ContributorAuthor

Mmh, some expected Information diagnostics are reported as Warning diagnostics.
I'll look into that tomorrow.

@0101

0101 commented Feb 9, 2024

Copy link
Copy Markdown
Contributor

The tests are now in main so you can undo dawedawe@b47ba47

Comment threadsrc/Compiler/Driver/CompilerDiagnostics.fs
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NO_RELEASE_NOTESLabel for pull requests which signals, that user opted-out of providing release notes

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants

@dawedawe@0101@majocha@T-Gro@nojaf