Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Fields with the same name in different classes collide

Abierto
#318 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
52/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
java
Área
compilers

Línea de trabajo

Reproduce the failure with the minimal Collision example, then inspect field handling in OperationsChecker and RefinementTypeChecker.visitCtFieldRead. Trace how field reads and writes are keyed in the context, including the declaring class and target expression. Done means the example verifies successfully and similarly named fields retain their distinct refinements.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug

Description

Fields are keyed in the context by name only (this#<name>), whatever class owns them and whatever the target expression is. Two fields with the same name in different classes (e.g. an outer class and a nested class) are treated as the same variable, so one is checked against the other's refinement.

Minimal reproducer

import liquidjava.specification.Refinement;

public class Collision {
    @Refinement("_ < 0") int port = -1;
    private final Job job = new Job();

    public void send() { job.port = 5; }

    static class Job { @Refinement("_ >= 0") int port; }
}

Expected

Correct! Passed Verification. (Job.port is _ >= 0.)

Actual

Refinement Error: this#port⁴ == 5 is not a subtype of this#port⁴ < 0
5 |     public void send() { job.port = 5; }
  |                          ^^^^^^^^^^^^^

The write to job.port is checked against Collision.port's refinement.

Cause

Field reads and writes use String.format(Formats.THIS, fieldName) (e.g. OperationsChecker, RefinementTypeChecker.visitCtFieldRead), with no owning class or target object. A fix would need to key fields by their declaring type, and ideally separate instances (this.port vs job.port).

Reproduced on main at fbfb4e23 (liquidjava-verifier 0.0.35).

Lenguaje dominante
Java
Estrellas
67
Forks
36
Merge medio
4 d 17 h
PR fusionados (30 d)
7

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de liquid-java/liquidjava

Todos los issues de liquid-java/liquidjava

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.