git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Do not allow variable shadowing #135
commit464a1ed8f82f523d5af01fb83854bd8b25c0f4c0 authorPhil Freeman <paf31@cantab.net> dateMon 27 Jan 2014, 20:57 (13 years ago) parent313a98b
2 files changed+13−1
examples/failing/Shadowed.purs+12 src/Language/PureScript/TypeChecker/Types.hs+1−1
examples/failing/Shadowed.pursnew file+12
@@ -0,0 +1,12 @@
1+module Shadowed where
2+
3+a = [1, 2]
4+
5+foo = {
6+ var x = a !! 0;
7+ var a = 0;
8+
9+ a = a + 1;
10+
11+ return x + a;
12+ }
src/Language/PureScript/TypeChecker/Types.hs+1−1
@@ -675,7 +675,7 @@ assignVariable name = do
675675 env <- checkEnv <$> get
676676 moduleName <- substCurrentModule <$> ask
677677 case M.lookup (moduleName, name) (names env) of
678− Just (_, LocalVariable) -> throwError $ "Variable with name " ++ show name ++ " already exists."
678+ Just _ -> throwError $ "Variable with name " ++ show name ++ " already exists."
679679 _ -> return ()
680680
681681-- |