Soundness: a field of another class or object is read as this class's field with the same name
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 76/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Java
- Stelle
- 67
- Fork
- 36
- Merge medio
- 4g 17h
- PR unite (30g)
- 7
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di liquid-java/liquidjava
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
liquid-java/liquidjava#321 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 68/100
liquid-java/liquidjava#323 ·
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
liquid-java/liquidjava#318 ·
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
liquid-java/liquidjava#317 ·
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 62/100
liquid-java/liquidjava#316 ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di liquid-java/liquidjava
Issue simili
-
Update license yearAperta0 - Backlog 1 - Ready documentation good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
cbor
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
FasterXML/jackson-dataformats-binary#844 ·
I maintainer di solito rispondono entro 1 giorno
-
Issue: Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
OpenAPITools/openapi-generator#25107 ·
I maintainer di solito rispondono entro 1 giorno
-
improvement
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
apache/iceberg#18351 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
repowise-dev/repowise#2945 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno