on master help sign in
Make error message a bit nicer when there is only one argument
780ee73Evan Czaplicki
src/Reporting/Error/Type.hs+12−2
@@ -62,7 +62,7 @@ data Hint
62 | BinopRight Var.Canonical Region.Region
62 | BinopRight Var.Canonical Region.Region
63 | Binop Var.Canonical
63 | Binop Var.Canonical
64 | Function (Maybe Var.Canonical)
64 | Function (Maybe Var.Canonical)
65− | UnexpectedArg (Maybe Var.Canonical) Int Region.Region
65+ | UnexpectedArg (Maybe Var.Canonical) Int Int Region.Region
66 | FunctionArity (Maybe Var.Canonical) Int Int Region.Region
66 | FunctionArity (Maybe Var.Canonical) Int Int Region.Region
67 | BadTypeAnnotation String
67 | BadTypeAnnotation String
68 | Instance String
68 | Instance String
@@ -268,7 +268,17 @@ mismatchToReport localizer (MismatchInfo hint leftType rightType maybeReason) =
268 []
268 []
269 )
269 )
270
270
271− UnexpectedArg maybeName index region ->
271+ UnexpectedArg maybeName 1 1 region ->
272+ report
273+ (Just region)
274+ ("The argument to " ++ funcName maybeName ++ " is causing a mismatch.")
275+ ( cmpHint
276+ (Help.capitalize (funcName maybeName) ++ " is expecting the argument to be:")
277+ "But it is:"
278+ []
279+ )
280+
281+ UnexpectedArg maybeName index _totalArgs region ->
272 report
282 report
273 (Just region)
283 (Just region)
274 ( "The " ++ Help.ordinalize index ++ " argument to " ++ funcName maybeName
284 ( "The " ++ Help.ordinalize index ++ " argument to " ++ funcName maybeName
src/Type/Constrain/Expression.hs+1−1
@@ -234,7 +234,7 @@ argConstraints env name region totalArgs overallVar index args =
234
234
235 let argMatchCon =
235 let argMatchCon =
236 CEqual
236 CEqual
237− (Error.UnexpectedArg name index subregion)
237+ (Error.UnexpectedArg name index totalArgs subregion)
238 region
238 region
239 (VarN argIndexVar)
239 (VarN argIndexVar)
240 (VarN argVar)
240 (VarN argVar)