Collision of interface constant and trait constant doesn't produce fatal error
未关闭
还没有人认领这个 Issue。
Bug
Category: Engine
Status: Verified
- 主要语言
- C
- 星标
- 40.4k
- 派生
- 8.1k
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 96
描述
Description
The following code:
<?php
trait MyTrait{
const A = 1;
}
interface I{
const A = 2;
}
class D implements I{
use MyTrait;
}
echo D::A;
Resulted in this output:
1
But I expected this output instead:
Fatal error: I and MyTrait define the same constant (A) in the composition of D. However, the definition differs and is considered incompatible. Class was composed in /in/EVuKh on line 10
PHP Version
8.2
Operating System
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先运行 issue 中的 PHP 8.2 复现脚本,并确认 trait 和 interface 常量解析为 1,而不是产生错误。追踪 class D 的 trait/interface 常量组合,然后添加一个显示预期 fatal error 的回归测试,并验证对于兼容的定义,现有行为得以保留。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- php
- 领域
- compilers
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 35/100