-
Notifications
You must be signed in to change notification settings - Fork 804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scoped nowarn #18049
base: main
Are you sure you want to change the base?
Scoped nowarn #18049
Conversation
❗ Release notes required
|
Hi @Martin521 - thanks for the contribution. It's a substantial effort and we appreciate it. The PR is on our radar - just keep in mind that it's big and specific, and it will take time to find capacity for it. If anyone from the community gets to thoroughly review it, that would be valuable as well. Thanks for your diligence and patience :) |
In any case, however, we need to get agreement on the main compatibility question. That's the question if we should remove the current inconsistency between Fsc and the IDEs regarding This is a question that should be discussed with the RFC, but here is the technical / historical background that gives rise to the question. The It seems that at some point then somebody wanted to create a better design. They created the field So, there are now inconsistent ways in which So, assuming we find a way to implement "warn scopes", should we implement it only for fsc, or everywhere? |
Probably hardcoded default names without a directory? Like this:
I'll try to replace the occurrences with generated names, shouldn't take long. |
If that's doable - that would be really great. |
@majocha - thanks for your relentless support here :) Indeed, this would be great. @Martin521 thanks for the detailed answer. I think I understand the inconsistency. We might want to discuss it a bit, but before that - what do you think is easier to do from the implementation perspective? Very generally speaking, the preference is: |
From an implementation point of view, a consistent implementation of warn scopes for all use cases is definitely simpler. It is simpler to implement and also enables us to remove all the complicated code around the old way of dealing with #nowarn. (If you want to have a taste of the code around the #nowarn collection that I mentioned above, have a look at |
@Martin521, so a consistent and simpler approach would be preferred here. In general, we count with breaking changes here. Another way to put it - when users start relying on bugs, fixing bugs becomes a breaking change. But often that's still the right way to go. We're currently having such discussion here. But it might require some communication and documentation later :) |
Thanks, that's very clear and I am glad you see it that way. First, however, I have now to dive still deeper into the uses of the global |
Sure, let's tackle issues one by one :) |
@Martin521, I'll mark this as draft - the sole purpose is for the team to get notified once the feedback is addressed and the PR is ready to review again. I am personally watching this closely anyway :) |
I have fixed the testing issue mentioned above. For those interested, here are some details. FileIndex.fileIndexTable is a global mutable resource that represents a bidirectional mapping between file paths and file indices.
This is all fine in any production scenario (fsc, fsi, FSAC), because all files have unique paths. Mapping to FileIndex and back is not a problem. In Testing, however, there are tests that use, in different tests, the same file path "test.fs" in what looks to the compiler service like the same project ("test.fsproj"). When these tests run in parallel, matching ranges by file index is no longer reliable because the same file index might now be used by different tests and a, say, #nowarn directive from one test might be matched against a warning range of another test. What were the options?
I went for the third option. Because it was simple to implement on the testing side (thanks to @majocha for providing the code), while implementing warn scopes under the first option would be very difficult. |
Now, finally, the answers to the questions.
This is completely covered by the compatibility section of the RFC. (Note that, currently, the code in this PR produces the new behavior for scripts (item e) independent of the feature flag. If we want to keep the old behavior for old language versions, this still needs to be fixed.)
The substantial changes in this PR are all based on one of two reasons. The second reason is the feature itself and the processing of the warn directives that it needs. Previously, the #nowarn directives were processed in a number of different places (postparse, fsc, fsi, bgCompiler, TransparentCompiler, FSharpCheckerResult, ScriptClosure) to make them land in either Every large refactoring comes, of course, also with risks. I want to put these risks here into two categories. The second category is about incompatibilities with the previous behavior.
This is a very good question. Currently, I cannot test any of the IDEs. If I knew how exactly the IDEs use the compiler service to obtain diagnostics, I would add tests for exactly these scenarios to FSharp.Compiler.Service.Tests. It might also make sense to add a few warn scope tests to vsintegration and/or FsAutoComplete. To have a session with some experts is a good idea. |
Thanks @Martin521 for the update and the response. I'll get to that tomorrow, stay tuned. |
Summoning @baronfel for FSAC thoughts :) |
So I think we are getting there. We generally two things:
|
Sorry I pressed the wrong button! |
Description
Implements Scoped Nowarn according to draft RFC FS-1146.
This PR has taken a while. I had to deal with much more complexity than I imagined when I naively volunteered to tackle the feature request. Anyway, here we are.
I have split the PR into 7 commits that can be reviewed in sequence.
All of them compile, 1 and 4 - 7 also pass all tests locally.
Add the feature flag, baseline tests, and the core
WarnScopes
module. Seesrc/Compiler/SyntaxTree/WarnScopes.fsi
and the RFC for the functionality of the module.Add the necessary changes to lexing and parsing. Note that the warn directives can no longer be collected during parsing (since they can now appear not only in top-level modules, but anywhere). So we collect them during lexing, similar to the processing of #if/#else/#endif directives.
Remove legacy #nowarn processing (but hold off AST changes)
Integrate the WarnScopes functionality and test it
Add warn directive trivia (but hold off AST changes)
Enable warn directive trivia (which means AST changes)
Remove defunct types and parameters related to former #nowarn processing (more AST changes)
There is also a separate commit for the IlVerify baseline updates (change in line numbers only)
Checklist