Skip to content

Commit

Permalink
Merge pull request #1506 from ndmitchell/zliu41/vars-matchgroup
Browse files Browse the repository at this point in the history
Fix freeVars computation for MatchGroup
  • Loading branch information
ndmitchell authored Jan 14, 2024
2 parents 7aaaecf + 302549d commit 4ec0c0a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/GHC/Util/FreeVars.hs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ instance AllVars (LocatedA (HsBindLR GhcPs GhcPs)) where
allVars (L _ (PatSynBind _ PSB{})) = mempty -- Come back to it.

instance AllVars (MatchGroup GhcPs (LocatedA (HsExpr GhcPs))) where
allVars (MG _ _alts@(L _ alts)) = inVars (foldMap (allVars . m_pats) ms) (allVars (map m_grhss ms))
allVars (MG _ _alts@(L _ alts)) = foldMap (\m -> inVars (allVars (m_pats m)) (allVars (m_grhss m))) ms
where ms = map unLoc alts

instance AllVars (LocatedA (Match GhcPs (LocatedA (HsExpr GhcPs)))) where
Expand Down
1 change: 1 addition & 0 deletions src/Hint/Lambda.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ foo = bar (\x -> case x of [y, z] -> z) -- \[y, z] -> z
yes = blah (\ x -> case x of A -> a; B -> b) -- \ case A -> a; B -> b
yes = blah (\ x -> case x of A -> a; B -> b) -- @Note may require `{-# LANGUAGE LambdaCase #-}` adding to the top of the file
no = blah (\ x -> case x of A -> a x; B -> b x)
no = blah (\ x -> case x of A -> a x; x -> b x)
foo = bar (\x -> case x of Y z | z > 0 -> z) -- \case Y z | z > 0 -> z
yes = blah (\ x -> (y, x)) -- (y,)
yes = blah (\ x -> (y, x, z+q)) -- (y, , z+q)
Expand Down

0 comments on commit 4ec0c0a

Please sign in to comment.