Mark patterns in lambda argument position as having a presence constraint

Closes #2299
This commit is contained in:
ayazhafiz 2021-12-30 18:21:28 -06:00
parent aaa041cee5
commit fda6c70835
2 changed files with 18 additions and 5 deletions

View file

@ -77,7 +77,7 @@ fn constrain_untyped_args(
loc_pattern.region, loc_pattern.region,
pattern_expected, pattern_expected,
&mut pattern_state, &mut pattern_state,
false, true,
); );
vars.push(*pattern_var); vars.push(*pattern_var);

View file

@ -1327,7 +1327,7 @@ mod solve_expr {
\Foo -> 42 \Foo -> 42
"# "#
), ),
"[ Foo ]* -> Num *", "[ Foo ] -> Num *",
); );
} }
@ -1339,7 +1339,7 @@ mod solve_expr {
\@Foo -> 42 \@Foo -> 42
"# "#
), ),
"[ @Foo ]* -> Num *", "[ @Foo ] -> Num *",
); );
} }
@ -1419,7 +1419,7 @@ mod solve_expr {
\Foo x -> Foo x \Foo x -> Foo x
"# "#
), ),
"[ Foo a ]* -> [ Foo a ]*", "[ Foo a ] -> [ Foo a ]*",
); );
} }
@ -1431,7 +1431,7 @@ mod solve_expr {
\Foo x _ -> Foo x "y" \Foo x _ -> Foo x "y"
"# "#
), ),
"[ Foo a * ]* -> [ Foo a Str ]*", "[ Foo a * ] -> [ Foo a Str ]*",
); );
} }
@ -4909,4 +4909,17 @@ mod solve_expr {
"{ x : [ Blue, Red ], y ? Num a }* -> Num a", "{ x : [ Blue, Red ], y ? Num a }* -> Num a",
) )
} }
#[test]
// Issue #2299
fn infer_union_argument_position() {
infer_eq_without_problem(
indoc!(
r#"
\UserId id -> id + 1
"#
),
"[ UserId (Num a) ] -> Num a",
)
}
} }