mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 16:21:11 +00:00
fix backpassing region
This commit is contained in:
parent
ffdd76903b
commit
4a3e90fdef
2 changed files with 40 additions and 8 deletions
|
@ -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 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 {
|
||||
Expr::Apply(function, arguments, called_via) => {
|
||||
|
|
|
@ -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
|
||||
"#
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue