Add test for #1755

Closes #1755
This commit is contained in:
Ayaz Hafiz 2022-06-07 14:34:45 -04:00
parent 5bee4e2d42
commit 3a41aeb3f6
No known key found for this signature in database
GPG Key ID: 0E2A37416A25EF58

View File

@ -10299,4 +10299,53 @@ All branches in an `if` must have the same type!
),
)
}
#[test]
fn issue_1755() {
new_report_problem_as(
"issue_1755",
indoc!(
r#"
Handle := {}
await : Result a err, (a -> Result b err) -> Result b err
open : {} -> Result Handle *
close : Handle -> Result {} *
withOpen : (Handle -> Result {} *) -> Result {} *
withOpen = \callback ->
handle <- await (open {})
{} <- await (callback handle)
close handle
withOpen
"#
),
indoc!(
r#"
TYPE MISMATCH /code/proj/Main.roc
Something is off with the body of the `withOpen` definition:
10 withOpen : (Handle -> Result {} *) -> Result {} *
11 withOpen = \callback ->
12> handle <- await (open {})
13> {} <- await (callback handle)
14> close handle
The type annotation on `withOpen` says this `await` call should have the
type:
Result {} *
However, the type of this `await` call is connected to another type in a
way that isn't reflected in this annotation.
Tip: Any connection between types must use a named type variable, not
a `*`! Maybe the annotation on `withOpen` should have a named type
variable in place of the `*`?
"#
),
)
}
}