Cannot disambiguate duplicate record fields while it can with OverloadedRecordDot
Summary
Cannot disambiguate duplicate record fields while it can with OverloadedRecordDot
Steps to reproduce
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE OverloadedRecordDot #-}
module Main where
-- create record
data Person = Person { name :: String, age :: Int } deriving (Show)
data Person1 = Person1 { name :: String, age :: Int } deriving (Show)
go :: Person -> String
go x = name x
go1 :: Person -> String
go1 x = x.name
Expected behavior
x.name
is correctly disambiguated,
while for name x
. It is confusing.
app/Main.hs:11:8: error: [GHC-87543]
Ambiguous occurrence ‘name’.
It could refer to
either the field ‘name’ of record ‘Person’,
defined at app/Main.hs:7:24,
or the field ‘name’ of record ‘Person1’,
defined at app/Main.hs:8:26.
|
11 | go x = name x
Environment
- GHC version used: Glasgow Haskell Compiler, Version 9.8.1, stage 2 booted by GHC version 9.4.4