diff --git a/infer/tests/codetoanalyze/erlang/features/issues.exp b/infer/tests/codetoanalyze/erlang/features/issues.exp index 960fd1e8b..4c3dd589d 100644 --- a/infer/tests/codetoanalyze/erlang/features/issues.exp +++ b/infer/tests/codetoanalyze/erlang/features/issues.exp @@ -27,6 +27,11 @@ codetoanalyze/erlang/features/src/comparison.erl, test_less_Bad/0, 3, NO_TRUE_BR codetoanalyze/erlang/features/src/comparison.erl, test_less_Bad2/0, 3, NO_TRUE_BRANCH_IN_IF, no_bucket, ERROR, [no true branch in if expression here] codetoanalyze/erlang/features/src/comparison.erl, test_not_equal_Bad/0, 3, NO_TRUE_BRANCH_IN_IF, no_bucket, ERROR, [no true branch in if expression here] codetoanalyze/erlang/features/src/comparison.erl, test_not_equal_Bad2/0, 3, NO_TRUE_BRANCH_IN_IF, no_bucket, ERROR, [no true branch in if expression here] +codetoanalyze/erlang/features/src/functions.erl, test_call1_Bad/0, -16, NO_MATCHING_FUNCTION_CLAUSE, no_bucket, ERROR, [calling context starts here,in call to `warn/1`,no matching function clause here] +codetoanalyze/erlang/features/src/functions.erl, test_call2_Bad/0, -30, NO_MATCHING_FUNCTION_CLAUSE, no_bucket, ERROR, [calling context starts here,in call to `warn/1`,no matching function clause here] +codetoanalyze/erlang/features/src/functions.erl, test_call3_Bad/0, -43, NO_MATCHING_FUNCTION_CLAUSE, no_bucket, ERROR, [calling context starts here,in call to `warn/1`,no matching function clause here] +codetoanalyze/erlang/features/src/functions.erl, test_call4_Bad/0, -55, NO_MATCHING_FUNCTION_CLAUSE, no_bucket, ERROR, [calling context starts here,in call to `warn/1`,no matching function clause here] +codetoanalyze/erlang/features/src/functions.erl, warn/1, 0, NO_MATCHING_FUNCTION_CLAUSE, no_bucket, ERROR, [*** LATENT ***,no matching function clause here] codetoanalyze/erlang/features/src/lists.erl, test_cons1_Bad/0, 4, NO_MATCHING_CASE_CLAUSE, no_bucket, ERROR, [no matching case clause here] codetoanalyze/erlang/features/src/lists.erl, test_cons2_Bad/0, 4, NO_MATCHING_CASE_CLAUSE, no_bucket, ERROR, [no matching case clause here] codetoanalyze/erlang/features/src/lists.erl, test_nil_Bad/0, 2, NO_MATCHING_CASE_CLAUSE, no_bucket, ERROR, [no matching case clause here] diff --git a/infer/tests/codetoanalyze/erlang/features/src/functions.erl b/infer/tests/codetoanalyze/erlang/features/src/functions.erl new file mode 100644 index 000000000..a0c2c1ab7 --- /dev/null +++ b/infer/tests/codetoanalyze/erlang/features/src/functions.erl @@ -0,0 +1,78 @@ +% Copyright (c) Facebook, Inc. and its affiliates. +% +% This source code is licensed under the MIT license found in the +% LICENSE file in the root directory of this source tree. + +-module(functions). +-export([ + test_call1_Ok/0, + test_call1_Bad/0, + test_call2_Ok/0, + test_call2_Bad/0, + test_call3_Ok/0, + test_call3_Bad/0, + test_call4_Ok/0, + test_call4_Bad/0 +]). + +% Call this method with warn(1) to trigger a warning to expect +warn(0) -> ok. + +f(1) -> 1; +f(_) -> 0. + +first(X, _) -> X. + +second(_, Y) -> Y. + +test_call1_Ok() -> + X = 5, + Y = f(X), + case Y of + 0 -> ok + end. + +test_call1_Bad() -> + X = 5, + Y = f(X), + case Y of + 0 -> warn(1) + end. + +test_call2_Ok() -> + X = 1, + Y = f(X), + case Y of + 1 -> ok + end. + +test_call2_Bad() -> + X = 1, + Y = f(X), + case Y of + 1 -> warn(1) + end. + +test_call3_Ok() -> + X = first(1, 2), + case X of + 1 -> ok + end. + +test_call3_Bad() -> + X = first(1, 2), + case X of + 1 -> warn(1) + end. + +test_call4_Ok() -> + X = second(1, 2), + case X of + 2 -> ok + end. + +test_call4_Bad() -> + X = second(1, 2), + case X of + 2 -> warn(1) + end.