summaryrefslogtreecommitdiff
path: root/testsuite/tests/overloadedrecflds/should_fail/T11103.hs
blob: 2ba8e41a2288b9ac1516a150b5bdd2e421ebe52a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-- When using DuplicateRecordFields with TemplateHaskell, it is not possible to
-- reify ambiguous names that are output by reifying field labels.
-- See also overloadedrecflds/should_run/overloadedrecfldsrun04.hs

{-# LANGUAGE DuplicateRecordFields, TemplateHaskell #-}

import Language.Haskell.TH
import Language.Haskell.TH.Syntax

data R = MkR { foo :: Int, bar :: Int }
data S = MkS { foo :: Int }

$(do info <- reify ''R
     case info of
       TyConI (DataD _ _ _ [RecC _ [(foo_n, _, _), (bar_n, _, _)]] _)
         -> do { reify bar_n -- This is unambiguous
               ; reify foo_n -- This is ambiguous
               ; return []
               }
       _ -> error "unexpected result of reify")