mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 00:01:16 +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 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) => {
|
||||||
|
|
|
@ -4526,16 +4526,16 @@ mod test_reporting {
|
||||||
indoc!(
|
indoc!(
|
||||||
r#"
|
r#"
|
||||||
── UNFINISHED PARENTHESES ──────────────────────────────────────────────────────
|
── UNFINISHED PARENTHESES ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
I am partway through parsing a type in parentheses, but I got stuck
|
I am partway through parsing a type in parentheses, but I got stuck
|
||||||
here:
|
here:
|
||||||
|
|
||||||
1│ f : ( I64
|
1│ f : ( I64
|
||||||
^
|
^
|
||||||
|
|
||||||
I was expecting to see a parenthesis before this, so try adding a )
|
I was expecting to see a parenthesis before this, so try adding a )
|
||||||
and see if that helps?
|
and see if that helps?
|
||||||
|
|
||||||
Note: I may be confused by indentation
|
Note: I may be confused by indentation
|
||||||
"#
|
"#
|
||||||
),
|
),
|
||||||
|
@ -6258,15 +6258,15 @@ mod test_reporting {
|
||||||
indoc!(
|
indoc!(
|
||||||
r#"
|
r#"
|
||||||
── NEED MORE INDENTATION ───────────────────────────────────────────────────────
|
── NEED MORE INDENTATION ───────────────────────────────────────────────────────
|
||||||
|
|
||||||
I am partway through parsing a type in parentheses, but I got stuck
|
I am partway through parsing a type in parentheses, but I got stuck
|
||||||
here:
|
here:
|
||||||
|
|
||||||
1│ Box : (
|
1│ Box : (
|
||||||
2│ Str
|
2│ Str
|
||||||
3│ )
|
3│ )
|
||||||
^
|
^
|
||||||
|
|
||||||
I need this parenthesis to be indented more. Try adding more spaces
|
I need this parenthesis to be indented more. Try adding more spaces
|
||||||
before it!
|
before it!
|
||||||
"#
|
"#
|
||||||
|
@ -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