Skip to content

DuplicateRecordFields allows duplicate record fields in the same record - and is unsound!

Summary

This also leads to ".. is not in scope during type checking, but it passed the renamer" internal error when you try to update the field.

Steps to reproduce

In GHCi

λ> :set -XDuplicateRecordFields
λ> data R = R {a :: Int, a :: Int } deriving Show
type R :: *
data R = ...
λ> (R 1 1){a = 2}

<interactive>:9:1: error:
     GHC internal error: interactive:Ghci1.$sel:a:R is not in scope during type checking, but it passed the renamer
      tcl_env of environment: []
     In the expression: (R 1 1) {a = 2}
      In an equation for it: it = (R 1 1) {a = 2}

Expected behavior

Duplicate record fields shouldn't be allowed in the same record

Environment

  • GHC version used: 8.10.3
Edited by Zubin
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information