Skip to content

Commit 887d413

Browse files
LiamGoodacrepaf31
authored andcommitted
Traversal should pick up bindings in all value declarations. (purescript#2412)
1 parent 6675280 commit 887d413

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

examples/warning/2411.purs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-- @shouldWarnWith ShadowedName
2+
module Main where
3+
4+
import Prelude
5+
6+
import Control.Monad.Eff (Eff)
7+
8+
test :: forall m. Monad m => Int -> m Unit
9+
test x =
10+
let x = unit
11+
in pure x
12+
13+
main :: Eff () Unit
14+
main = test 42
15+

src/Language/PureScript/AST/Traversals.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,8 @@ everythingWithScope f g h i j = (f'', g'', h'', i'', \s -> snd . j'' s)
474474
in foldMap (f'' s') ds
475475
f' s (ValueDeclaration name _ bs (Right val)) =
476476
let s' = S.insert name s
477-
in foldMap (h'' s') bs <> g'' s' val
477+
s'' = S.union s' (S.fromList (concatMap binderNames bs))
478+
in foldMap (h'' s') bs <> g'' s'' val
478479
f' s (ValueDeclaration name _ bs (Left gs)) =
479480
let s' = S.insert name s
480481
s'' = S.union s' (S.fromList (concatMap binderNames bs))

0 commit comments

Comments
 (0)