git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #838 from purescript/824

Fix #822

commit0d621eb961f25b520a3f3d1dbfce45baf51fc434 authorPhil Freeman <paf31@cantab.net> dateTue 3 Feb 2015, 08:35 (12 years ago) parentf52ad0203fc6b6
3 files changed+15−3
examples/failing/DuplicateDeclarationsInLet.purs+9 src/Language/PureScript/Sugar/Names.hs+5−2 src/Language/PureScript/TypeChecker.hs+1−1
examples/failing/DuplicateDeclarationsInLet.pursnew file+9
@@ -0,0 +1,9 @@
1+module Main where
2+
3+foo = a
4+ where
5+ a :: Number
6+ a = 1
7+
8+ a :: Number
9+ a = 2
src/Language/PureScript/Sugar/Names.hs+5−2
@@ -219,9 +219,12 @@ renameInModule imports exports (Module mn decls exps) =
219219 updateValue :: (Maybe SourceSpan, [Ident]) -> Expr -> Either ErrorStack ((Maybe SourceSpan, [Ident]), Expr)
220220 updateValue (_, bound) v@(PositionedValue pos' _ _) = return ((Just pos', bound), v)
221221 updateValue (pos, bound) (Abs (Left arg) val') = return ((pos, arg : bound), Abs (Left arg) val')
222− updateValue (pos, bound) (Let ds val') =
222+ updateValue (pos, bound) (Let ds val') = do
223223 let args = mapMaybe letBoundVariable ds
224− in return ((pos, args ++ bound), Let ds val')
224+ unless (length (nub args) == length args) $
225+ throwError $ maybe id (\p e -> positionError p <> e) pos $ mkErrorStack ("Overlapping names in let binding.") Nothing
226+ return ((pos, args ++ bound), Let ds val')
227+ where
225228 updateValue (pos, bound) (Var name'@(Qualified Nothing ident)) | ident `notElem` bound =
226229 (,) (pos, bound) <$> (Var <$> updateValueName name' pos)
227230 updateValue (pos, bound) (Var name'@(Qualified (Just _) _)) =
src/Language/PureScript/TypeChecker.hs+1−1
@@ -89,7 +89,7 @@ addTypeClass moduleName pn args implies ds =
8989
9090addTypeClassDictionaries :: [TypeClassDictionaryInScope] -> Check ()
9191addTypeClassDictionaries entries =
92− let mentries = M.fromList [ ((canonicalizeDictionary entry, mn), entry) | entry@TypeClassDictionaryInScope{ tcdName = Qualified mn _ } <- entries ]
92+ let mentries = M.fromList [ ((canonicalizeDictionary entry, mn), entry) | entry@TypeClassDictionaryInScope{ tcdName = Qualified mn _ } <- entries ]
9393 in modify $ \st -> st { checkEnv = (checkEnv st) { typeClassDictionaries = (typeClassDictionaries . checkEnv $ st) `M.union` mentries } }
9494
9595checkDuplicateTypeArguments :: [String] -> Check ()