Re: [VOTE] throw expression
| From: | Ilija Tovilo | Date: | Sun, 05 Apr 2020 10:53:15 +0000 |
| Subject: | Re: [VOTE] throw expression | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-109534@lists.php.net to get a copy of this message | ||
Hi Dan
> Did the RFC get updated to address this?
>
> As the current behaviour listed* in the RFC seems wrong and surprising to me.
I did respond to that e-mail but probably got classified as spam as
were the other e-mails I sent with that address. This was my response:
> I've thought about this some more. There is a reasonable way to recognize this, namely to
> check if the expression after the throw keyword is of type ZEND_AST_OR or ZEND_AST_AND. The
> expression above will fail with this message (given that $condition is false):
>
> > Fatal error: Uncaught Error: Can only throw objects in ...
>
> IMO this is clear enough that a message for this edge case is not necessary.
We could improve the error message by printing the type that got
passed to throw:
> Fatal error: Uncaught Error: Can only throw objects, bool given in ...
Regards,
Ilija