summaryrefslogtreecommitdiff
path: root/compiler/GHC/Types/Name/Occurrence.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/GHC/Types/Name/Occurrence.hs')
-rw-r--r--compiler/GHC/Types/Name/Occurrence.hs9
1 files changed, 6 insertions, 3 deletions
diff --git a/compiler/GHC/Types/Name/Occurrence.hs b/compiler/GHC/Types/Name/Occurrence.hs
index 8aecadf71e..964c313abd 100644
--- a/compiler/GHC/Types/Name/Occurrence.hs
+++ b/compiler/GHC/Types/Name/Occurrence.hs
@@ -465,9 +465,12 @@ varToRecFieldOcc dc (OccName ns s) =
assert makes_sense $ mkRecFieldOccFS dc s
where
makes_sense = case ns of
- VarName -> True
- FldName con -> con == dc
- _ -> False
+ VarName -> True
+ FldName {} -> True
+ -- NB: it's OK to change the parent data constructor,
+ -- see e.g. test T23220 in which we construct with TH
+ -- a datatype using the fields of a different datatype.
+ _ -> False
recFieldToVarOcc :: HasDebugCallStack => OccName -> OccName
recFieldToVarOcc (OccName _ns s) = mkVarOccFS s