Skip to content

Commit

Permalink
[erlang] More tests on matching against already bound variables
Browse files Browse the repository at this point in the history
Summary: Add a test for simple "reassignment" and using the anonymus placeholder `_`.

Reviewed By: lisztspace

Differential Revision: D62126763

fbshipit-source-id: a8779efb7148a19db7e7fb1158fd68b1c9d15a70
  • Loading branch information
hajduakos authored and facebook-github-bot committed Sep 3, 2024
1 parent aa0489c commit e2d96a8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions infer/tests/codetoanalyze/erlang/compiler/issues.exp
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,11 @@ nonmatch_match_expr:fn_test_match_func_arg_Bad/0: badmatch
nonmatch_match_expr:fn_test_match_func_args_Bad/0: badmatch
nonmatch_match_expr:fn_test_match_with_var_Bad/0: badmatch
nonmatch_match_expr:fn_test_match_with_var_swapped_Bad/0: badmatch
nonmatch_match_expr:fn_test_not_real_anon_match1_Bad/0: badmatch
nonmatch_match_expr:fn_test_not_real_anon_match2_Bad/0: badmatch
nonmatch_match_expr:fn_test_simple_match_Bad/0: badmatch
nonmatch_match_expr:test_match_a_Ok/0: ok
nonmatch_match_expr:test_match_anonymus_Ok/0: ok
nonmatch_match_expr:test_match_b_Bad/0: badmatch
nonmatch_match_expr:test_match_c_Ok/0: ok
nonmatch_match_expr:test_match_d_Ok/0: ok
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
test_match_with_var_Ok/0,
fn_test_match_with_var_Bad/0,
test_match_with_var_swapped_Ok/0,
fn_test_match_with_var_swapped_Bad/0
fn_test_match_with_var_swapped_Bad/0,
fn_test_simple_match_Bad/0,
test_match_anonymus_Ok/0,
fn_test_not_real_anon_match1_Bad/0,
fn_test_not_real_anon_match2_Bad/0
]).

tail([_ | Xs]) -> Xs.
Expand Down Expand Up @@ -165,3 +169,21 @@ test_match_with_var_swapped_Ok() ->

fn_test_match_with_var_swapped_Bad() ->
crash_if_not_one_with_var_swapped(2).

fn_test_simple_match_Bad() ->
A = 1,
A = 2.

test_match_anonymus_Ok() ->
_ = 1,
_ = 2.

fn_test_not_real_anon_match1_Bad() ->
% `_` is the only truly anonymus name
_A = 1,
_A = 2.

fn_test_not_real_anon_match2_Bad() ->
% `_` is the only truly anonymus name
__ = 1,
__ = 2.

0 comments on commit e2d96a8

Please sign in to comment.