DisambiguateRecordFields, not DuplicateRecordFields, should control name resolution for record updates
At the moment, the DuplicateRecordFields
extension changes name resolution for record updates so that it is sufficient for one type (or, following #21443 (closed), one constructor) to have all the fields being updated. I claim that this behaviour should be enabled by the DisambiguateRecordFields
extension instead. This would mean DisambiguateRecordFields
controls all the special name lookup rules for use sites, while DuplicateRecordFields
merely allows the definition of the same field name multiple times in the same module. (I'm assuming a post-#19461 world where the type-directed resolution is gone.)
Since DuplicateRecordFields
implies DisambiguateRecordFields
, this change should almost always accept more programs.
Concretely, the following program is rejected with ambiguity errors on the record update, but I think it should be accepted:
module MS where
data S = MkS { x :: Int }
module MT where
data T = MkT { x :: Int, y :: Int }
module MU where
data U = MkU { y :: Int }
{-# LANGUAGE DisambiguateRecordFields #-} -- using DuplicateRecordFields here instead would work already
module N where
import MS
import MT
import MU
eg r = r { x = 1, y = 1 }
@sheaf you may have an opinion as this relates to !8686 (merged)?