Collision of interface constant and trait constant doesn't produce fatal error
オープン
まだ誰も着手していません。
Bug
Category: Engine
Status: Verified
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.1k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 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 にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず issue にある PHP 8.2 の再現スクリプトを実行し、trait と interface の定数がエラーを発生させずに 1 として解決されることを確認します。次に、class D における trait/interface 定数の合成を追跡し、期待される fatal error を示す回帰テストを追加して、互換性のある定義では既存の動作が維持されることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- php
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 35/100