[GHC] #15149: Identical distinct type family fields miscompiled
GHC
ghc-devs at haskell.org
Sat Jun 9 07:40:54 UTC 2018
#15149: Identical distinct type family fields miscompiled
-------------------------------------+-------------------------------------
Reporter: NeilMitchell | Owner: adamgundry
Type: bug | Status: new
Priority: normal | Milestone: 8.6.1
Component: Compiler | Version: 8.4.2
Resolution: | Keywords: ORF
Operating System: Unknown/Multiple | Architecture:
Type of failure: GHC rejects | Unknown/Multiple
valid program | Test Case:
Blocked By: | Blocking:
Related Tickets: #14747 | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by adamgundry):
I think I've come across a simpler way to fix this and #14747. At the
moment, `rnHsRecFields` goes to some trouble to figure out the parent type
constructor of the data constructor (in `find_tycon`) and then does field
name lookup using the parent type constructor. But we already have
`lookupConstructorFields` which lets us directly find out the
`FieldLabel`s of a data constructor! (This is used for expanding dot-dot
patterns.)
So why don't we just use `lookupConstructorFields` and search amongst them
for the right one? We'd need to be a bit careful to still check the name
is in scope (with the right module qualifier, if any), but that should be
simple if we know the unambiguous selector name already.
Moving field label resolution to the typechecker still might be worth
doing, because it should get rid of quite a bit of duplication. But it's
not a small task (e.g. because of dot-dot patterns) so I think it's worth
pursuing the small fix first.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15149#comment:9>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list