diff options
author | Fredrik Gustafsson <fredrik@erlang.org> | 2013-04-10 17:55:25 +0200 |
---|---|---|
committer | Fredrik Gustafsson <fredrik@erlang.org> | 2013-04-10 17:55:25 +0200 |
commit | c55f2caf26cdb9709f06412de0feece4e95e5574 (patch) | |
tree | c246c1779ca33b991665d4654e795957f796634a /lib/dialyzer/test | |
parent | 92727b2d911362c1efc8df84cf685c91f154e15a (diff) | |
parent | 071bffb32b861a6cf3f2d715d7c92eeda4dfcb16 (diff) | |
download | otp-c55f2caf26cdb9709f06412de0feece4e95e5574.tar.gz otp-c55f2caf26cdb9709f06412de0feece4e95e5574.tar.bz2 otp-c55f2caf26cdb9709f06412de0feece4e95e5574.zip |
Merge branch 'sa/dialyzer-bitstring-fixes/OTP-11027' into maint
* sa/dialyzer-bitstring-fixes/OTP-11027:
Minor refactorings
Fix minor error in natively compiled module list
Fix notification for duplicate modules
Fix an error in the type inference of bitstring data
Diffstat (limited to 'lib/dialyzer/test')
-rw-r--r-- | lib/dialyzer/test/small_SUITE_data/src/bs_constraints.erl | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/dialyzer/test/small_SUITE_data/src/bs_constraints.erl b/lib/dialyzer/test/small_SUITE_data/src/bs_constraints.erl new file mode 100644 index 0000000000..08dfb0808d --- /dev/null +++ b/lib/dialyzer/test/small_SUITE_data/src/bs_constraints.erl @@ -0,0 +1,32 @@ +%% Program which shows that the handling of binaries was not correct. +%% The success typing inferred was: +%% -spec bits1(<<_:3>>) -> <<_:3>>. +%% while it should be: +%% -spec bits1(<<_:3,_:_*1>>) -> <<_:3>>. +%% because the only constraint which exists for the head variable is +%% that it must be a bitstring of bit size at least 3, not a bitstring +%% of bit size 3. +-module(bs_constraints). + +-export([bits1/1, bits2/1, bits3/1, bins/1, test/0]). + +bits1(B) -> + <<B:3/bits>>. + +bits2(B) -> + <<B:4/bits>>. + +bits3(B) -> + {bits1(B), bits2(B)}. + +%% Same problem with the one below. The success typing should be: +%% -spec bins(<<_:16,_:_*1>>) -> <<_:16>>. +bins(B) -> + <<B:2/binary>>. + +%% Same problem, when unit size is a variable: +test() -> + foo(8, 0, <<42>>). + +foo(N, S, A) -> + <<A:S/binary-unit:1, A:(N-S)/binary-unit:1>>. |