2ba8e41a2288b9ac1516a150b5bdd2e421ebe52a
[ghc.git] / testsuite / tests / overloadedrecflds / should_fail / T11103.hs
1 -- When using DuplicateRecordFields with TemplateHaskell, it is not possible to
2 -- reify ambiguous names that are output by reifying field labels.
3 -- See also overloadedrecflds/should_run/overloadedrecfldsrun04.hs
4
5 {-# LANGUAGE DuplicateRecordFields, TemplateHaskell #-}
6
7 import Language.Haskell.TH
8 import Language.Haskell.TH.Syntax
9
10 data R = MkR { foo :: Int, bar :: Int }
11 data S = MkS { foo :: Int }
12
13 $(do info <- reify ''R
14 case info of
15 TyConI (DataD _ _ _ [RecC _ [(foo_n, _, _), (bar_n, _, _)]] _)
16 -> do { reify bar_n -- This is unambiguous
17 ; reify foo_n -- This is ambiguous
18 ; return []
19 }
20 _ -> error "unexpected result of reify")