Skip to content

Commit 38b6332

Browse files
Don't count it as using a term if you only destruct it (#2099)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 8a471bb commit 38b6332

File tree

5 files changed

+7
-3
lines changed

5 files changed

+7
-3
lines changed

plugins/hls-tactics-plugin/src/Wingman/CodeGen.hs

-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ destruct' use_field_puns f hi jdg = do
225225
$ disallowing AlreadyDestructed (S.singleton term) jdg
226226
pure $ ext
227227
& #syn_trace %~ rose ("destruct " <> show term) . pure
228-
& #syn_used_vals %~ S.insert term
229228
& #syn_val %~ noLoc . case' (var' term)
230229

231230

plugins/hls-tactics-plugin/src/Wingman/Tactics.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ assume name = rule $ \jdg -> do
6363
-- reasonable for a default value.
6464
(pure (noLoc $ var' name))
6565
{ syn_trace = tracePrim $ "assume " <> occNameString name
66-
, syn_used_vals = S.singleton name
66+
, syn_used_vals = S.singleton name <> getAncestry jdg name
6767
}
6868
Nothing -> cut
6969

@@ -298,7 +298,7 @@ apply (Unsaturated n) hi = tracing ("apply' " <> show (hi_name hi)) $ do
298298
) saturated_args
299299
pure $
300300
ext
301-
& #syn_used_vals %~ S.insert func
301+
& #syn_used_vals %~ (\x -> S.insert func x <> getAncestry jdg func)
302302
& #syn_val %~ mkApply func . fmap unLoc
303303

304304
application :: TacticsM ()

plugins/hls-tactics-plugin/test/CodeAction/AutoSpec.hs

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ spec = do
4949
autoTest 2 25 "AutoInfixInfix"
5050
autoTest 19 12 "AutoTypeLevel"
5151
autoTest 11 9 "AutoForallClassMethod"
52+
autoTest 2 8 "AutoUnusedPatternMatch"
5253

5354
failing "flaky in CI" $
5455
autoTest 2 11 "GoldenApplicativeThen"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
test :: Bool -> ()
2+
test _ = ()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
test :: Bool -> ()
2+
test = _

0 commit comments

Comments
 (0)