@@ -184,7 +184,7 @@ checkDefinition (Valid.Definition pattern body _) =
185 case pattern of
185 case pattern of
186 A.A _ (Pattern.Var _) ->
186 A.A _ (Pattern.Var _) ->
187− return ()
187+ checkArguments args
@@ -194,6 +194,38 @@ checkDefinition (Valid.Definition pattern body _) =
194 Result.throw (R.merge start end) (Error.BadFunctionName (length args))
194 Result.throw (R.merge start end) (Error.BadFunctionName (length args))
198+checkArguments :: [Pattern.Pattern R.Region var] -> Result.Result wrn Error.Error ()
199+checkArguments args =
201+ vars = concatMap (Pattern.boundVarList) args
203+ case firstDuplicate vars of
209+ (A.A start _) = head args
210+ (A.A end _) = last args
212+ Result.throw (R.merge start end) (Error.RepeatedArgument var)
215+firstDuplicate :: [String] -> Maybe String
216+firstDuplicate vars =
222+ if var `elem` rest then
197-- VALIDATE EXPRESSIONS
229-- VALIDATE EXPRESSIONS
199expression :: Source.Expr -> Result.Result wrn Error.Error Valid.Expr
231expression :: Source.Expr -> Result.Result wrn Error.Error Valid.Expr