Skip to content

Invariant inference: mark inferred facts in diagnostics, and a hint to state a loop invariant #554

Open

Description

@CatarinaGamboa

Part of #548 (decisions in its comments) and the loop invariant plan #542.

1. Mark inferred facts. The facts that loop invariant inference adds to a loop-head instance must be recognisable in the diagnostic data sent to the IDE: which conjuncts of Found are inferred invariants and the line of their loop. The terminal/hover message does not change: inferred facts stay inside Found as ordinary facts.

2. Hint (prototype). When an error's counterexample involves a variable that an enclosing loop changes, and inference could not prove what is needed, add a hint: the variable changes in the loop at line N, LiquidJava only keeps what holds on every iteration, and the invariant can be stated on the declaration, e.g. @Refinement("_ >= 0") int total = 0; (the suggested refinement is the expected refinement rewritten for the variable, when that is possible). Judge it on real examples (#537's loops, study-like code) before keeping it; drop it if it misleads.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementerror messages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions