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

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

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

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

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.

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

描述

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.

主要语言
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 摘要。