@@ -20,7 +20,7 @@ module Language.PureScript.Sugar.CaseDeclarations (
22import Data.Monoid ((<>))
22import Data.Monoid ((<>))
23−import Data.List (groupBy)
23+import Data.List (nub, groupBy)
25import Control.Applicative
25import Control.Applicative
26import Control.Monad ((<=<), forM, join, unless, replicateM)
26import Control.Monad ((<=<), forM, join, unless, replicateM)
@@ -31,6 +31,7 @@ import Language.PureScript.Declarations
31import Language.PureScript.Environment
31import Language.PureScript.Environment
32import Language.PureScript.Errors
32import Language.PureScript.Errors
33import Language.PureScript.Supply
33import Language.PureScript.Supply
34+import Language.PureScript.TypeChecker.Monad (guardWith)
36-- Replace all top-level binders in a module with case expressions.
37-- Replace all top-level binders in a module with case expressions.
@@ -82,6 +83,7 @@ toDecls :: [Declaration] -> SupplyT (Either ErrorStack) [Declaration]
82toDecls [ValueDeclaration ident nameKind bs Nothing val] | all isVarBinder bs = do
83toDecls [ValueDeclaration ident nameKind bs Nothing val] | all isVarBinder bs = do
83 let args = map (\(VarBinder arg) -> arg) bs
84 let args = map (\(VarBinder arg) -> arg) bs
84 body = foldr (Abs . Left) val args
85 body = foldr (Abs . Left) val args
86+ guardWith (strMsg "Overlapping function argument names") $ length (nub args) == length args
85 return [ValueDeclaration ident nameKind [] Nothing body]
87 return [ValueDeclaration ident nameKind [] Nothing body]
86toDecls ds@(ValueDeclaration ident _ bs _ _ : _) = do
88toDecls ds@(ValueDeclaration ident _ bs _ _ : _) = do
87 let tuples = map toTuple ds
89 let tuples = map toTuple ds