fix backpassing region

This commit is contained in:
Folkert 2021-04-09 12:02:50 +02:00
parent ffdd76903b
commit 4a3e90fdef
2 changed files with 40 additions and 8 deletions

View file

@ -223,7 +223,7 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a
let desugared_ret = desugar_expr(arena, loc_ret); let desugared_ret = desugar_expr(arena, loc_ret);
let closure = Expr::Closure(loc_patterns, desugared_ret); let closure = Expr::Closure(loc_patterns, desugared_ret);
let loc_closure = Located::at_zero(closure); let loc_closure = Located::at(loc_expr.region, closure);
match &desugared_body.value { match &desugared_body.value {
Expr::Apply(function, arguments, called_via) => { Expr::Apply(function, arguments, called_via) => {

View file

@ -6303,4 +6303,36 @@ mod test_reporting {
), ),
) )
} }
#[test]
fn backpassing_type_error() {
report_problem_as(
indoc!(
r#"
x <- List.map [ "a", "b" ]
x + 1
"#
),
indoc!(
r#"
TYPE MISMATCH
The 2nd argument to `map` is not what I expect:
1> x <- List.map [ "a", "b" ]
2>
3> x + 1
This argument is an anonymous function of type:
Num a -> Num a
But `map` needs the 2nd argument to be:
Str -> Num a
"#
),
)
}
} }