Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance type analysis #7563

Merged
merged 6 commits into from
Aug 17, 2023
Merged

Enhance type analysis #7563

merged 6 commits into from
Aug 17, 2023

Commits on Aug 15, 2023

  1. Add types for more BIFs

    bjorng committed Aug 15, 2023
    Configuration menu
    Copy the full SHA
    f1906a8 View commit details
    Browse the repository at this point in the history
  2. Enhance range analysis for integer division

    Teach beam_bounds:bound/3 to determine a range for the `div` operator
    when nothing is known about the divisor. For example:
    
        div0(A, B) when is_integer(A), 0 =< A, A < 1204 ->
            %% Range for A is 0..1023
            A div B.                % Range is -1023..1023
    bjorng committed Aug 15, 2023
    Configuration menu
    Copy the full SHA
    ad264fc View commit details
    Browse the repository at this point in the history
  3. Enhance range analysis for the rem operator

    Teach beam_bounds:bound/3 to determine a range for the `rem` operator
    when nothing is known about the right-hand side operand. For example:
    
        rem0(A, B) when is_integer(A), 0 =< A, A < 1204 ->
            %% Range for A is 0..1023
            A rem B.                % Range is 0..1023 (same as for A)
    bjorng committed Aug 15, 2023
    Configuration menu
    Copy the full SHA
    acf3116 View commit details
    Browse the repository at this point in the history
  4. Enhance range analysis for the bsl operator

    Teach beam_bounds:bounds/3 to calculate a range for the `bsl` operator
    when the left-hand side operand is partly unbounded. For example:
    
        bsl0(A) when is_integer(A), A >= 1 ->
            %% Range for A is 1..'+inf'
            A bsl 3.                % Range is 8..'+inf'
    
        bsl1(A) when is_integer(A), A =< 10 ->
            %% Range for A is '-inf'..10
            A bsl 3.                % Range is '-inf'..80
    bjorng committed Aug 15, 2023
    Configuration menu
    Copy the full SHA
    a71c2c6 View commit details
    Browse the repository at this point in the history
  5. Enhance range analysis for the bor operator

    Teach beam_bounds:bounds/3 to calculate a range for the `bor` operator
    for negative or partly unbounded arguments. For example:
    
        bor0(A) when is_integer(A), -10 =< A, A =< 10 ->
            %% Range for A is -10..10
            A bor 1.                % Range is '-inf'..11
    
        bor1(A, B) when is_integer(A), A < 0, is_integer(B), B < 0 ->
            %% Range for A and B is '-inf'..-1
            A bor B.                % Range is '-inf'..-1
    
        bor2(A, B) when is_integer(A), A >= 1, is_integer(B), B >= 10 ->
            %% Range for A is 1..'+inf'; range for B is 10..'+inf'
            A bor B.                % Range is 10..'+inf'
    bjorng committed Aug 15, 2023
    Configuration menu
    Copy the full SHA
    7e33bac View commit details
    Browse the repository at this point in the history
  6. Enhance range analysis for the * operator

    Teach beam_bounds:bound/3 to determine a range for the `*` operator
    when both factors have a non-negative lower bound. For example:
    
        m(A, B) when is_integer(A), A >= 2, is_integer(B), B >= 10 ->
            %% Range for A is 2..'+inf'; range for B is 10..'+inf'
            A * B < 100.            % Range for A * B is 20..'+inf'
    bjorng committed Aug 15, 2023
    Configuration menu
    Copy the full SHA
    c5979b0 View commit details
    Browse the repository at this point in the history