You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following three tests fail, we should expect that a get_x not returning an option won't unify with my_map/2's second argument and thus fail but the typer accepts the integer argument instead of rejecting it. I have not yet confirmed or denied that this behaviour is limited to records.
, fun() ->
Code =
"module fun_pattern_with_adt\n\n"
"type option 'a = None | Some 'a\n\n"
"my_map _ None = None\n\n"
"my_map f Some a = Some (f a)\n\n"
"doubler x = x * x\n\n"
"foo = my_map doubler 2",
?assertMatch(
{error, {cannot_unify, _, _, #adt{}, t_int}},
module_typ_and_parse(Code))
end
, fun() ->
Code =
"module fun_pattern_with_adt\n\n"
"type option 'a = None | Some 'a\n\n"
"my_map _ None = None\n\n"
"my_map f Some a = Some (f a)\n\n"
"doubler x = x * x\n\n"
"get_x {x=x} = x\n\n"
"foo () = "
" let rec = {x=1, y=2} in "
" my_map doubler (get_x rec)",
?assertMatch(
{error, {cannot_unify, _, _, #adt{}, t_int}},
module_typ_and_parse(Code))
end
, fun() ->
Code =
"module fun_pattern_with_adt\n\n"
"type option 'a = None | Some 'a\n\n"
"my_map _ None = None\n\n"
"my_map f Some a = Some (f a)\n\n"
"doubler x = x * x\n\n"
"get_x rec = match rec with {x=x} -> x\n\n"
"foo () = "
" let rec = {x=1, y=2} in "
" my_map doubler (get_x rec)",
?assertMatch(
{error, {cannot_unify, _, _, #adt{}, t_int}},
module_typ_and_parse(Code))
end
The text was updated successfully, but these errors were encountered:
The following three tests fail, we should expect that a
get_x
not returning an option won't unify withmy_map/2
's second argument and thus fail but the typer accepts the integer argument instead of rejecting it. I have not yet confirmed or denied that this behaviour is limited to records.The text was updated successfully, but these errors were encountered: