Skip to content

Add Constant Propagation And Folding To Predicates #58

Description

@rcosta358

Why

Adding constant propagation and constant folding to predicates would greatly simplify the error messages in many cases.

Example

public class Example {
    
    public static void handleNegative(@Refinement("x < 0") int x) {}
    
    public static void example() {
        int a = 6;
        int b = 2;
        int result = a / b;
        handleNegative(result);
    }
}

Current error message:

Type expected: (#result_4 < 0)
Refinement found: #result_4 == #a_2 / #b_3 && #a_2 == #a_0 && #a_0 == 6 && #b_3 == #b_1 && #b_1 == 2

Intended error message:

Type expected: (#result_4 < 0)
Refinement found: #result_4 == 3

So, the variables a and b should be propagated with their constant values to 6 / 2 and then this should be folded to 3.
This should also work for booleans, e.g. !true => false.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions