diff options
author | Ivan Dubrov <[email protected]> | 2011-07-13 15:25:01 +0700 |
---|---|---|
committer | Henrik Nord <[email protected]> | 2011-08-17 09:16:37 +0200 |
commit | b4f5b85d0a7f288db70093d806920d004d8b0e83 (patch) | |
tree | 4c5f76e1eee32f588b7c546ae95e7f4a1e8e4313 | |
parent | 964f6fce397193fb1a6235d7aaed474b6868d73e (diff) | |
download | otp-b4f5b85d0a7f288db70093d806920d004d8b0e83.tar.gz otp-b4f5b85d0a7f288db70093d806920d004d8b0e83.tar.bz2 otp-b4f5b85d0a7f288db70093d806920d004d8b0e83.zip |
Fix dialyzer warning on default clause for binary comprehension
Fixed dialyzer warning occuring on binary comprehension of form
"<< <<>> || {A, B} <- [{a, b}] >>" caused by default clause
inserted by compiler. Since this clause is different from the
case of list comprehension, dialyzer fails to suppress that warning.
-rw-r--r-- | lib/dialyzer/src/dialyzer_dataflow.erl | 11 | ||||
-rw-r--r-- | lib/dialyzer/test/small_SUITE_data/src/binary_lc_bug.erl | 8 |
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/dialyzer/src/dialyzer_dataflow.erl b/lib/dialyzer/src/dialyzer_dataflow.erl index 121667b5a5..8cb16d8f09 100644 --- a/lib/dialyzer/src/dialyzer_dataflow.erl +++ b/lib/dialyzer/src/dialyzer_dataflow.erl @@ -1414,6 +1414,17 @@ do_clause(C, Arg, ArgType0, OrigArgType, Map, false -> true end; + [Pat0, Pat1] -> % binary comprehension + case cerl:is_c_cons(Pat0) of + true -> + not (cerl:is_c_var(cerl:cons_hd(Pat0)) andalso + cerl:is_c_var(cerl:cons_tl(Pat0)) andalso + cerl:is_c_var(Pat1) andalso + cerl:is_literal(Guard) andalso + (cerl:concrete(Guard) =:= true)); + false -> + true + end; _ -> true end; false -> diff --git a/lib/dialyzer/test/small_SUITE_data/src/binary_lc_bug.erl b/lib/dialyzer/test/small_SUITE_data/src/binary_lc_bug.erl new file mode 100644 index 0000000000..c1e82bfa59 --- /dev/null +++ b/lib/dialyzer/test/small_SUITE_data/src/binary_lc_bug.erl @@ -0,0 +1,8 @@ +-module(test). + +-export([bin_compr/0]). + +bin_compr() -> +% [ 0 || {N, V} <- [{a, b}] ]. % Works ok + << <<>> || {A, B} <- [{a, b}] >>. % Complains +% << <<>> || X <- [{a, b}] >>. % Works ok |