Soundness: a field write through another object of the same class (`o.x = 5`) is applied to `this.x`

Ouverte
#438 0 commentaires 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é
3/5
Temps estimé
1-2 jours
Accessibilité débutants
66/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
java
Domaine
testing-qa

Piste de recherche

Start with RefinementTypeChecker.visitAssignment at RefinementTypeChecker.java:255-258 and compare its field write handling with visitCtFieldRead and Utils.accessesTrackedField, which the issue says handles reads. Use the minimal Repro example to check the current result and the control without the write. Done when the same-class write no longer makes verification incorrectly pass and the expected refinement error is reported.

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

Description

bug

Impact: a real violation passes verification (missed error).

Description

A field write through another object of the same class (o.x = 5) is recorded as a write to this.x. RefinementTypeChecker.visitAssignment (RefinementTypeChecker.java:255-258) names every CtFieldWrite with Utils.qualifyFieldName, whatever its target. #322 fixed this for reads (visitCtFieldRead checks Utils.accessesTrackedField); this is the write side. Writes to a field of another class (a.x = 5 with A a) and reads of o.x are handled correctly. A write whose target is not this could skip the update of this.x, or havoc it since o may be this.

Minimal reproducer

import liquidjava.specification.Refinement;

public class Repro {
    int x;

    void m(Repro o) {
        o.x = 5;
        @Refinement("_ == 5") int k = this.x;   // this.x is unknown
    }
}

Expected

A Refinement Error at k (this.x may be anything).

Actual

Correct! Passed Verification.

Control: without o.x = 5

Refinement Error: k¹ == x is not a subtype of k¹ == 5

Not a duplicate of #340: that one is about a field's initializer being assumed in another method; here the value comes from a write to a different object in the same method.

Reproduced on main at 1a506fea (liquidjava-verifier 0.0.36).

Context

Found while reviewing #432. Related: #322.

🤖 Generated with Claude Code

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.