forked from erlang/otp
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
4 changed files
with
73 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>>. |