In-source return refinement `_ == true --> s(this)` binds `this` to the return value (Argument Mismatch)

Ouverte
#442 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
1-2 jours
Accessibilité débutants
55/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
java
Domaine
backend, testing-qa

Piste de recherche

Start with the in-source verifier path for @Refinement return clauses and compare how it binds this with the external-spec path. Run the one-file reproducer from the issue and confirm the boolean versus Edit argument mismatch; use the stated external refinement example as a comparison. Done when the in-source example verifies and the external example continues to verify.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

bug

A boolean method that reveals a state when it returns true, @Refinement("_ == true --> b(this)"), fails when the class is annotated in its own source. The same form verifies in an @ExternalRefinementsFor spec.

Reproducer (one file; run the verifier on it):

import liquidjava.specification.Refinement;
import liquidjava.specification.StateRefinement;
import liquidjava.specification.StateSet;

@StateSet({"a", "b"})
class Edit {
    @StateRefinement(to = "a(this)")
    public Edit() {}

    @StateRefinement(to = "b(this)")
    public void finish() {}

    @Refinement("_ == true --> b(this)")
    public boolean isDone() { return true; }

    @StateRefinement(from = "b(this)")
    public void needsB() {}
}

public class Main {
    static void use(Edit e) {
        if (e.isDone()) e.needsB();   // a true answer says b
    }
    public static void main(String[] args) { Edit e = new Edit(); e.finish(); use(e); }
}

Found on main @ f7f366c (also on 1a506fe):

Argument Mismatch Error: Argument '#ret_6' and its respective parameter of ghost 'Edit.state1' types are incompatible: expected Edit, got boolean
19 |     public boolean isDone() { return true; }

this in the return refinement seems to be bound to the return value (#ret_6) instead of the receiver.

Expected: the program verifies, as it does when the same refinements are written in an external spec. For example, this one verifies:

@ExternalRefinementsFor("javax.swing.undo.AbstractUndoableEdit")
@StateSet({"done", "undone"})
public interface EditRefinements {
    @StateRefinement(to = "done(this)") void AbstractUndoableEdit();
    @Refinement("_ == true --> done(this)") boolean canUndo();
    @StateRefinement(from = "done(this)", to = "undone(this)") void undo();
}
// client: static void use(AbstractUndoableEdit e) { if (e.canUndo()) e.undo(); }

Found while cataloguing spec forms for co-specification; the reproducers are probes V11 (in-source) and V21 (external) there. Low priority: external specs, the main use, work.

Langage dominant
Java
Étoiles
73
Forks
38
Merge moyen
12 h 32 min
PR mergées (30 j)
45

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de liquid-java/liquidjava

Toutes les issues de liquid-java/liquidjava

Issues similaires

Plus d'issues Java

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.