This is a minimal reproducing example for bug in GHC. It is observed in 8.6.3 (Stack LTS-13.6), 8.6.5 (nix) and 8.8.1 (nix).
$ ghc Exp.hs -ddump-splices
[1 of 2] Compiling TH ( TH.hs, TH.o )
[2 of 2] Compiling Exp ( Exp.hs, Exp.o )
Exp.hs:11:1-10: Splicing declarations make ''Bar ======>
Exp.hs:11:1: error:
Ambiguous occurrence ‘Exp.foo’
It could refer to
either the field ‘foo’, defined at Exp.hs:9:18
or the field ‘foo’, defined at Exp.hs:8:18
|
11 | make ''Bar
| ^^^^^^^^^^
TH function make
only calls reify
and does nothing, as is seen from -ddump-splices
. However, reify
on record
fields triggers a very weird error with DuplicateRecordFields
.