-
Notifications
You must be signed in to change notification settings - Fork 815
Scoped nowarn #18049
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
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 :) |
I thought ParsedInput. That's where the data is created, so should stay in sync. |
This won't work, because in |
First, thanks to @T-Gro and @majocha for testing and reviewing this. However, I do understand your reluctance to accept code that is sensitive to certain constellations that were not problem so far but are seen as "inconsistency" by my code. (And also, I don't know how difficult it will be to find a repro for the mistake in order to fix it.) I therefore want to try once more to find an alternative to the tcConfig.diagnosticsOptions solution. I have an idea that I need to check. To still answer the question of @T-Gro about Anyway, my ask is for some time to check the alternative that I mentioned above. |
@Martin521,
After few tries I was able to get it stuck in a wrong state. Making some edit that is not yet cached makes it work again. Recording.2025-04-09.233442.mp4 |
Again this is with TransparentCompiler: Recording.2025-04-09.234141.mp4 |
Thanks! |
I just noticed |
It seems in TransparentCompiler the file version part of the cache key is not reliably updated on edits. But I have not yet found the place where it goes wrong. |
The above issue happens only in a certain situation in interactive (IDE) use and only when The last commits that I have pushed should fix this (hopefully last) issue. Here is the long story for those interested. I first have to state again why the warn scope data are stored in Following the RFC, we want the warn directives to behave consistently across all compiler modes, i.e. in fsc-compiled .fs/.fsi files, in fsc-compiled .fsx files, in the IDEs (compiler service), and in fsi compilation (both scripts and interactive). This means we have to replace two existing mechanisms (one in fsc and one for the other cases) by a single new one. (The fsc mechanism stores the #nowarn information during post-parse in To use the current fsc mechanism also for the other cases turns out to be impossible. At least not before a BIG cleanup of the whole diagnostics logging and background compiler / fsi. The call hierarchies leading to post-parse and to This has been implemented and works nicely everywhere except for the situation mentioned above. Here is what's happening. The TC caches parse and check results. Caching is based on keys. For the parse cache, the key is (if we simplify the matter a little) just the file name and a hash of the file content (source text). If during editing the content changes, the file is parsed again (including update of the warn scope data in the project's What can we do now? a) Postpone "scoped nowarn" (beyond F# 10) and first do a lot of cleanup. Remove a lot of the code duplication in the many compilation paths. Unify/simplify diagnostics logging for the different paths. Finish TC (bring it to production quality) and remove the old background compiler. Replace the current hack that implements #line directives by something sensible. Etc etc. (TBH, in hindsight, we should never have started "scoped nowarn" without the cleanup.) b) Fix the issue by disabling parse result caching. This is a serious and simple option. I don't think it will affect performance in a significant way. Parsing takes little resources compared to type checking. (Also, ironically, c) Fix the issue by making sure the parse cache key is changed (incremented) with every edit. This would be a fix with zero performance impact. But implementing it requires a quite deep redesign of the TC. I have implemented b) now, leaving a) and c) to a next step. |
Thanks for the explanation @Martin521. If I understood it correctly, caching non-changing data is fine. Which means that the only way problem can appear is if there are 2+ entries in the parsing cache, for the same file. (one current and one "to go back"). I do not like the approach to fully disable the parsing cache - there are tooling needs also for parsed results and we do have a tooling layer which simply assumes content is cached if it is not changing. (i.e. tooling happily asks for parsed results multiple times for various operations). Could you please elaborate any possible downsides of an approach b2:
Would there be any downsides then? |
Let me look into "b2" (size 1 cache), it sounds like a very good idea. |
Making the cache single-version was easier than I thought (here). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @Martin521 for your patience with fixing the outstanding IDE scenarios!
This is a big contribution and will improve the capabilities for handling warnings in F# codebases!
Head branch was pushed to by a user without write access
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