Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

Soundness: a field of another class or object is read as this class's field with the same name

Ouverte
#322 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 2 jours

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
76/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
java
Domaine
compilers

Piste de recherche

Start at OperationsChecker.getOperationRefinements and RefinementTypeChecker.visitCtFieldRead, using the supplied Limits/Repro example as the first reproducer. Trace how CtFieldRead targets are resolved for class fields, object fields, and enum constants, then verify that the reproducer reports a refinement error and that the name-clash cases no longer use the current class's field refinement.

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

Description

bug

Description

Reading a field of another class or object (Limits.max, other.val) resolves to the current class's own field with the same name (this.max) when the current class has one. The wrong refinement is used, so real violations are accepted.

Minimal reproducer

import liquidjava.specification.Refinement;

class Limits {
    static final int max = 10;
}

public class Repro {
    int max = 5;                       // this class also has a field named max

    void check() {
        @Refinement("_ == 5") int k = Limits.max;   // expected error: Limits.max is 10
    }
}

Expected

A refinement error: Limits.max is 10, not 5.

Actual

Correct! Passed Verification.

Removing the field int max = 5; from Repro gives the expected error (k == 10 is not a subtype of k == 5), so the name clash is what hides it.

Reproduced on main at fbfb4e23.

Where

OperationsChecker.getOperationRefinements / RefinementTypeChecker.visitCtFieldRead: a CtFieldRead is named with Formats.THIS (this#<name>) regardless of its target, so any field read whose simple name matches a field of the current class picks up that field's refinement. The same shape affects enum constants (Format.JPG read as this.JPG when the class has a field JPG) and fields of other objects (other.val read as this.val).

Context

Found by the adversarial review of #319 (fix for #302). Pre-existing on main, independent of #319.

Langage dominant
Java
Étoiles
67
Forks
36
Merge moyen
3 j 16 h
PR mergées (30 j)
9

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.