Warnings in TH expressions (pre-splice) should be suppressible
Tested with GHC 8.10.1:
I have a top-level TH splice that looks like this:
thGenerate $ \(~[decl1Rep, decl2Rep]) -> [d| decl1 :: ... decl1 = ... decl1Rep ... decl2Rep ... decl2 :: ... decl2 = ... decl1Rep ... decl2Rep ... |]
thGenerate is implemented using the
mfix from #12073 (closed), so it only ever passes a list with the correct amount of elements (e.g.
[decl1Rep, decl2Rep]) into the function given to it on the RHS of the expression. Of course I don't expect the compiler to be able to figure this out, but it would be good to have a flag to suppress the warning generated - the code is run at compile-time, so the warning is not relevant to any runtime event or condition.
Currently I can suppress the warning using
-Wno-incomplete-uni-patterns, but this also suppresses regular warnings for runtime code.
Note that this is different from #14838 which talks about generated code (e.g. in the
[d| ... |] on the RHS of the expression. Those warnings precisely should not be suppressed as part of this ticket, since they are for code that runs at runtime.
Note that this is also different from the suggestion in this comment which again is about code that runs at runtime.
This ticket is only about code that is run at compile time (by the TH splicer), that does not itself run at runtime.