Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Fields with the same name in different classes collide

未关闭
#318 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
52/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
java
领域
compilers

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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).

主要语言
Java
星标
67
派生
36
平均合并
4 天 17 小时
30 天内合并 PR
7

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

liquid-java/liquidjava 的其他 Issue

查看 liquid-java/liquidjava 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。