sublimehq / Packages

Syntax highlighting files shipped with Sublime Text and Sublime Merge
https://sublimetext.com
Other
2.95k stars 588 forks source link

[PHP] Incorrect error highlight for arrow functions that throws in function argument #4026

Closed Bocom closed 3 months ago

Bocom commented 3 months ago

What happened?

Using an arrow function that throws an exception as a function argument causes the last parenthesis after the throw key to be incorrectly highlighted as an error.

Code snippet

$exception = new Exception('Test exception');
some_function(fn() => throw $exception);
some_function(fn() => throw $exception, 'some other argument');

Screenshot

image

jfcherng commented 3 months ago

Fwiw, throw ... is an expression as of PHP 8.0. Previously, it's a statement. https://wiki.php.net/rfc/throw_expression