haskell / haskell/error-messages
Inappropriate error message for ambiguous record updates
- Dominant language
- No language data
- Stars
- 76
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Description
When a record update is ambiguous under `DuplicateRecordFields` (i.e. there are multiple fields in scope with the same name as the field being updated) the error message says it requires a type signature. However support for disambiguating updates by type is being removed from future GHC versions (this starts in GHC 9.2 which discourages such updates with a warning).
For example:
```hs
{-# LANGUAGE DuplicateRecordFields #-}
data S = MkS { foo :: Int }
data T = MkT { foo :: Int }
t = (MkT 0) { foo = 2 }
```
gives rise to:
```
AmbiguousUpdate3.hs:4:5: error:
• Record update is ambiguous, and requires a type signature
• In the expression: (MkT 0) {foo = 2}
In an equation for ‘t’: t = (MkT 0) {foo = 2}
|
4 | t = (MkT 0) { foo = 2 }
| ^^^^^^^^^^^^^^^^^^^
```
However, adding a type signature gives:
```
AmbiguousUpdate3.hs:4:15: warning: [-Wambiguous-fields]
The record update (MkT 0) {foo = 2} with type T is ambiguous.
This will not be supported by -XDuplicateRecordFields in future releases of GHC.
|
4 | t = (MkT 0) { foo = 2 } :: T
| ^^^^^^^
```
I think we should change the message in the first case to remove "requires a type signature". But perhaps it could include some additional explanation about what "record update is ambiguous" means, and how to fix it?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.