mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-11 05:34:11 +03:00
Merge pull request #1170 from rtfeldman/fix-backpassing-region
fix backpassing region
This commit is contained in:
commit
136f965a97
@ -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) => {
|
||||
|
@ -4526,16 +4526,16 @@ mod test_reporting {
|
||||
indoc!(
|
||||
r#"
|
||||
── UNFINISHED PARENTHESES ──────────────────────────────────────────────────────
|
||||
|
||||
|
||||
I am partway through parsing a type in parentheses, but I got stuck
|
||||
here:
|
||||
|
||||
|
||||
1│ f : ( I64
|
||||
^
|
||||
|
||||
|
||||
I was expecting to see a parenthesis before this, so try adding a )
|
||||
and see if that helps?
|
||||
|
||||
|
||||
Note: I may be confused by indentation
|
||||
"#
|
||||
),
|
||||
@ -6258,15 +6258,15 @@ mod test_reporting {
|
||||
indoc!(
|
||||
r#"
|
||||
── NEED MORE INDENTATION ───────────────────────────────────────────────────────
|
||||
|
||||
|
||||
I am partway through parsing a type in parentheses, but I got stuck
|
||||
here:
|
||||
|
||||
|
||||
1│ Box : (
|
||||
2│ Str
|
||||
3│ )
|
||||
^
|
||||
|
||||
|
||||
I need this parenthesis to be indented more. Try adding more spaces
|
||||
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…
Reference in New Issue
Block a user