Exceptions thrown during yield operation fall through the generator instead of being handled within
オープン
まだ誰も着手していません。
Bug
Category: Engine
Status: Verified
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.1k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
The following code:
<?php
set_error_handler(function() { throw new \Error(); });
function &gen() {
try {
yield 1;
} catch (Error $e) {
print "Caught";
}
}
foreach (gen() as $y);
Resulted in Uncaught Error
But I expected this output instead:
Caught
return_by_ref has the same problem, it seems to me, however in generators there's the additional case of exceptions in destructors of previous key and values.
I wouldn't change the longstanding behaviour in current PHP versions, but should be fixed for PHP 8.2 possibly, for academical correctness at least.
PHP Version
master
Operating System
No response
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
提供された generator の例を PHP master 上で再現し、観測されたエラーフローを期待される catch の動作と比較する。次に、generator の yield 処理、参照による return の動作、および記載されている destructor のケースを調査する。報告されたシナリオについて、意図した例外処理が定義され、カバーされており、確立された動作を意図せず変更していなければ完了とする。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- php
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100