Allow catching as ParseError "Non-abstract method C::foo() must contain a body"
未关闭
还没有人认领这个 Issue。
Feature
Status: Needs Triage
- 主要语言
- C
- 星标
- 40.4k
- 派生
- 8.1k
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 96
描述
Description
Since PHP 7 it is possible to catch syntax errors in PHP files during inclusion, which is a very nice feature, such as:
try {
eval("class C { function foo() }");
}
catch (\Throwable $e) {
print "CAUGHT [" . get_class($e) . "]: " . $e->getMessage() . "\n";
}
// prints: CAUGHT [ParseError]: syntax error, unexpected token "}", expecting ";" or "{"
// execution continues
Unfortunately, the same is not possible in case the error is a non-abstract method without body:
try {
eval("class C { function foo(); }");
}
catch (\Throwable $e) {
print "CAUGHT [" . get_class($e) . "]: " . $e->getMessage() . "\n";
}
// prints: Fatal error: Non-abstract method C::foo() must contain body in /in/YY0Wu(13) : eval()'d code on line 1
// execution terminates
Would it be possible to implement a throw also for this case?
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 PHP 解释器中的 eval() 路径开始,比较所示语法错误如何变成 ParseError,以及非 abstract 方法检查当前如何终止执行。使用 issue 中的两个 eval() 示例作为 reproducer;当第二种情况可以作为 ParseError 捕获且执行继续时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- php
- 领域
- compilers
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100