-
Notifications
You must be signed in to change notification settings - Fork 175
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
Fix future clause warnings introduced by upcoming sail release #689
base: master
Are you sure you want to change the base?
Conversation
I don't like this; it silences what would otherwise be actual legitimate incomplete match warnings. That is, now if a new extension is added you don't get a new warning, but previously you would. |
Open to other approaches, but we definitely need to do something otherwise we will introduce new warnings with the next Sail update. Maybe @Alasdair has a suggestion? |
My view is that the existence of this warning for this code is a bug in the Sail compiler and so should be fixed there. For non-scattered matches it perhaps makes sense, but this warning does not seem to me like a sensible thing to be doing for scattered matches. |
Note that rems-project/sail#825 uses a non-scattered match as the motivating example, and there are no tests that use a scattered match. I strongly believe this warning was not intended to occur here and this is an oversight in its implementation. |
Yeah, I just found the same thing and agree that it should probably not apply for scattered matches. Will open an issue against sail. |
I'm guessing this is a result of how scattered definitions are handled. Internally the individual clauses are collected and turned into a single non-scattered definition at the site of the final clause, not where the (I forget if it's legal to not include an end, but if so then probably scattered matches without an end should not warn, since they're still open) |
Yeah I noticed this too. An extra problem is that when we use the new project file you'll theoretically be able to exclude entire extensions from compilation (I think this helps the SV/formal backends), but since I put all of the Also maybe I'm blind but how does this PR fix the warning for |
That's a good point. I hadn't considered the interaction with the module system. It seems like maybe the wildcard match is the way to go then. It means we won't get warnings if someone forgets to implement an
For |
But if they forget to implement extensionEnabled they should get a warning! |
Yeah definitely, but I can't see a way to achieve that given all the constraints. |
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.
The other obvious options are to turn the warning off in Sail (I suspect it's too noisy to be useful), or if you do put in a wildcard clause make it an |
If the compiler were fixed to handle scattered functions more sensibly for this warning then that would achieve it? That’s the right thing to do… |
As I mentioned in my reply on the Sail issue there is a little bit of subtlety in this issue. For context: Now OCaml 5 is a thing, one of the things I've been doing is re-architecting the Sail frontend to make it more (amenable to) parallelism via separate compilation of different modules and files. In that context, scattered definitions present a bit a of an issue because you don't necessarily have all the information about all the clauses if they are being checked separately. That's why at the moment the completeness checker is just treating all scattered definitions as 'open' in the sense that it's just assuming that other separately checked thing could be adding clauses that we don't know about. Without a global check, handling this warning more sensibly would I think require checking that each module/compilation unit extends the function and enumeration clause in a 1-to-1 way (For example a module adding three new enumeration members, also adds the three corresponding function clauses). I think that's possible in theory but I haven't worked through the details in my head. |
Unfortunately I think that even that wouldn't work in this case because all of the extensions are listed in extensions.sail. If we exclude a particular module then the |
Yes, that's a good point I hadn't considered. |
The in-development next version of Sail introduces new warnings to catch incomplete pattern matching from potential future clauses. This refactors
riscv_insts_end.sail
to avoid this by adding a new wildcard match for undefined extensions and reordering theend
clauses.