File tree Expand file tree Collapse file tree 4 files changed +27
-3
lines changed
plugins/hls-tactics-plugin Expand file tree Collapse file tree 4 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -56,9 +56,17 @@ wildifyT (S.map occNameString -> used) = everywhere $ mkT $ \case
56
56
------------------------------------------------------------------------------
57
57
-- | Replace a 'VarPat' with the given @'Pat' GhcPs@.
58
58
rewriteVarPat :: Data a => RdrName -> Pat GhcPs -> a -> a
59
- rewriteVarPat name rep = everywhere $ mkT $ \ case
60
- VarPat _ (L _ var) | eqRdrName name var -> rep
61
- (x :: Pat GhcPs ) -> x
59
+ rewriteVarPat name rep = everywhere $
60
+ mkT (\ case
61
+ VarPat _ (L _ var) | eqRdrName name var -> rep
62
+ (x :: Pat GhcPs ) -> x
63
+ )
64
+ `extT` \ case
65
+ HsRecField lbl _ True
66
+ | eqRdrName name $ unLoc $ rdrNameFieldOcc $ unLoc lbl
67
+ -> HsRecField lbl (toPatCompat rep) False
68
+ (x :: HsRecField' (FieldOcc GhcPs ) (PatCompat GhcPs )) -> x
69
+
62
70
63
71
64
72
------------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ spec = do
20
20
destructTest " gadt" 7 17 " GoldenGADTDestruct.hs"
21
21
destructTest " gadt" 8 17 " GoldenGADTDestructCoercion.hs"
22
22
destructTest " a" 7 25 " SplitPattern.hs"
23
+ destructTest " a" 6 18 " DestructPun.hs"
23
24
24
25
describe " layout" $ do
25
26
destructTest " b" 4 3 " LayoutBind.hs"
Original file line number Diff line number Diff line change
1
+ {-# LANGUAGE NamedFieldPuns #-}
2
+
3
+
4
+ data Foo = Foo { a :: Bool , b :: Bool }
5
+
6
+ foo Foo {a, b} = _
7
+
Original file line number Diff line number Diff line change
1
+ {-# LANGUAGE NamedFieldPuns #-}
2
+
3
+
4
+ data Foo = Foo { a :: Bool, b :: Bool }
5
+
6
+ foo Foo {a = False, b} = _
7
+ foo Foo {a = True, b} = _
8
+
You can’t perform that action at this time.
0 commit comments