on master help sign in
Make error message a bit nicer when there is only one argument

Used to say “The 1st argument to `sort`” which implied there is a 2nd or something. Now it says “The argument to `sort`” which makes it clearer that there’s just one argument total.

commit780ee73c0f4502d231940f8aa76bf909c37a247c authorEvan Czaplicki <info@elm-lang.org> dateThu 22 Oct 2015, 03:06 (11 years ago) parent407cbc8
2 files changed+13−3
src/Reporting/Error/Type.hs+12−2 src/Type/Constrain/Expression.hs+1−1
src/Reporting/Error/Type.hs+12−2
@@ -62,7 +62,7 @@ data Hint
6262 | BinopRight Var.Canonical Region.Region
6363 | Binop Var.Canonical
6464 | Function (Maybe Var.Canonical)
65− | UnexpectedArg (Maybe Var.Canonical) Int Region.Region
65+ | UnexpectedArg (Maybe Var.Canonical) Int Int Region.Region
6666 | FunctionArity (Maybe Var.Canonical) Int Int Region.Region
6767 | BadTypeAnnotation String
6868 | Instance String
@@ -268,7 +268,17 @@ mismatchToReport localizer (MismatchInfo hint leftType rightType maybeReason) =
268268 []
269269 )
270270
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 ->
272282 report
273283 (Just region)
274284 ( "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 =
234234
235235 let argMatchCon =
236236 CEqual
237− (Error.UnexpectedArg name index subregion)
237+ (Error.UnexpectedArg name index totalArgs subregion)
238238 region
239239 (VarN argIndexVar)
240240 (VarN argVar)