@@ -20,7 +20,7 @@ module Language.PureScript.Sugar.CaseDeclarations (
2020) where
2121
2222import Data.Monoid ((<>))
23−import Data.List (groupBy)
23+import Data.List (nub, groupBy)
2424
2525import Control.Applicative
2626import Control.Monad ((<=<), forM, join, unless, replicateM)
@@ -31,6 +31,7 @@ import Language.PureScript.Declarations
3131import Language.PureScript.Environment
3232import Language.PureScript.Errors
3333import Language.PureScript.Supply
34+import Language.PureScript.TypeChecker.Monad (guardWith)
3435
3536-- |
3637-- Replace all top-level binders in a module with case expressions.
@@ -82,6 +83,7 @@ toDecls :: [Declaration] -> SupplyT (Either ErrorStack) [Declaration]
8283toDecls [ValueDeclaration ident nameKind bs Nothing val] | all isVarBinder bs = do
8384 let args = map (\(VarBinder arg) -> arg) bs
8485 body = foldr (Abs . Left) val args
86+ guardWith (strMsg "Overlapping function argument names") $ length (nub args) == length args
8587 return [ValueDeclaration ident nameKind [] Nothing body]
8688toDecls ds@(ValueDeclaration ident _ bs _ _ : _) = do
8789 let tuples = map toTuple ds