Open kozross opened 4 years ago
I'm not sure if these warnings are spurious or not - the record projection x{bar=1}
is indeed an incomplete pattern which doesn't match Quux. Ignoring these warnings seems like a possible failure mode, and reporting it doesn't seem unreasonable.
Because of the fix for #31 this went a way because I'm not using record updates at all. Not sure whether that's a good thing or not, but it's what happened.
I'm still getting this issue on the latest version. The only change I made to the above example was setting the version of record-dot-preprocessor
to 0.2.6
.
I didn't perfectly match the bug, but rewrote it in my test suite - perhaps missing some essential detail. I'll take another look tomorrow.
Ah, I was experimenting with the preprocessor, which triggered the same bug, not the plugin. Annoyingly, the plugin doesn't work on Windows, so I'm mostly relying on the CI, and I had a stray -w
to ignore all warnings in the plugin. I've fixed the CI, which should now fail, and will investigate further.
So the plugin currently requires -Wno-incomplete-record-updates
. Fixing it will involve a reasonable amount of time, so I'd accept a patch, but currently have no intention to do so myself. In the Plugin code, instead of generating r{selector=x}
it would be necessary to generate a full case alternative. But that might error, so it would be necessary to fake up an error message. But then you are approximately replacing an error message the compiler can see and warn on, with one it can't, which leaves me a little uneasy. My recommendation for now would just be to disable that specific warning, since you are likely doing incomplete record updates, albeit through the RecordDotSyntax.
@ndmitchell I understand your reasoning, but our chief issue isn't so much that such an incomplete update triggers a warning, it's where this warning is triggered. Currently, this is at the time (and in the module) where the type is defined, rather than at point of use, where it would actually be useful. Therefore, we have to silence this warning anywhere we want to use RecordDotSyntax and we define a sum type which uses record syntax in any of its 'arms' - even if we don't use the update syntax in that module at all!
@kozross Yep, totally agreed. I actually did a whole PhD on trying to move the warnings about incompleteness from their definition site to their use site! I'd much rather GHC worked that way, but its unlikely to do so in the near or medium term. As such, I'd accept a patch converting us from incomplete record updates to a case match - but don't have the bandwidth to do so myself - and am on the fence about whether it's a good idea (but if someone feels strong enough to implement it, I'll take that as evidence that my weak preferences aren't too relevant and happily merge).
Given a source file as so:
And a Cabal file as so:
Attempting to compile triggers these spurious warnings:
Without enabling the GHC plugin for the record dot syntax, these don't appear. I'd rather not have to silence this (useful) warning or constantly have to filter it for false positives. Am I doing something wrong here?