diff --git a/crates/reporting/src/error/parse.rs b/crates/reporting/src/error/parse.rs index 2b4f33caf3..8da55ccc68 100644 --- a/crates/reporting/src/error/parse.rs +++ b/crates/reporting/src/error/parse.rs @@ -279,8 +279,8 @@ fn to_expr_report<'a>( alloc.reflow("The arrow "), alloc.parser_suggestion("->"), alloc.reflow(" is only used to define cases in a "), - alloc.keyword("when"), - alloc.reflow("."), + alloc.keyword("`when`"), + alloc.reflow("expression:"), ]), alloc .vcat(vec![ @@ -289,6 +289,13 @@ fn to_expr_report<'a>( alloc.text("Green -> \"go!\"").indent(4), ]) .indent(4), + alloc.reflow("And to define a function:"), + alloc + .vcat(vec![ + alloc.text("increment : I64 -> I64"), + alloc.text("increment = \\n -> n + 1"), + ]) + .indent(4), ])] } }, diff --git a/crates/reporting/tests/test_reporting.rs b/crates/reporting/tests/test_reporting.rs index da3db9af29..452b009380 100644 --- a/crates/reporting/tests/test_reporting.rs +++ b/crates/reporting/tests/test_reporting.rs @@ -5645,11 +5645,17 @@ All branches in an `if` must have the same type! 5│ 1 -> True ^^ - The arrow -> is only used to define cases in a `when`. + The arrow -> is used to define cases in a `when` expression: when color is Red -> "stop!" Green -> "go!" + + And to define a function: + + increment : I64 -> I64 + increment = \n -> n + 1 + "### );