git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #838 from purescript/824
0d621ebPhil Freeman
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) =
219 updateValue :: (Maybe SourceSpan, [Ident]) -> Expr -> Either ErrorStack ((Maybe SourceSpan, [Ident]), Expr)
219 updateValue :: (Maybe SourceSpan, [Ident]) -> Expr -> Either ErrorStack ((Maybe SourceSpan, [Ident]), Expr)
220 updateValue (_, bound) v@(PositionedValue pos' _ _) = return ((Just pos', bound), v)
220 updateValue (_, bound) v@(PositionedValue pos' _ _) = return ((Just pos', bound), v)
221 updateValue (pos, bound) (Abs (Left arg) val') = return ((pos, arg : bound), Abs (Left arg) val')
221 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
223 let args = mapMaybe letBoundVariable ds
223 let args = mapMaybe letBoundVariable ds
224+ unless (length (nub args) == length args) $
225+ throwError $ maybe id (\p e -> positionError p <> e) pos $ mkErrorStack ("Overlapping names in let binding.") Nothing
224− in return ((pos, args ++ bound), Let ds val')
226+ return ((pos, args ++ bound), Let ds val')
227+ where
225 updateValue (pos, bound) (Var name'@(Qualified Nothing ident)) | ident `notElem` bound =
228 updateValue (pos, bound) (Var name'@(Qualified Nothing ident)) | ident `notElem` bound =
226 (,) (pos, bound) <$> (Var <$> updateValueName name' pos)
229 (,) (pos, bound) <$> (Var <$> updateValueName name' pos)
227 updateValue (pos, bound) (Var name'@(Qualified (Just _) _)) =
230 updateValue (pos, bound) (Var name'@(Qualified (Just _) _)) =
src/Language/PureScript/TypeChecker.hs+1−1
@@ -89,7 +89,7 @@ addTypeClass moduleName pn args implies ds =
89
89
90addTypeClassDictionaries :: [TypeClassDictionaryInScope] -> Check ()
90addTypeClassDictionaries :: [TypeClassDictionaryInScope] -> Check ()
91addTypeClassDictionaries entries =
91addTypeClassDictionaries 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 ]
93 in modify $ \st -> st { checkEnv = (checkEnv st) { typeClassDictionaries = (typeClassDictionaries . checkEnv $ st) `M.union` mentries } }
93 in modify $ \st -> st { checkEnv = (checkEnv st) { typeClassDictionaries = (typeClassDictionaries . checkEnv $ st) `M.union` mentries } }
94
94
95checkDuplicateTypeArguments :: [String] -> Check ()
95checkDuplicateTypeArguments :: [String] -> Check ()