[php-src] Issue #9398: Attempting to alias keywords results in a cryptic Parse error
| From: | Girgias | Date: | Mon, 22 Aug 2022 12:49:23 +0000 |
| Subject: | [php-src] Issue #9398: Attempting to alias keywords results in a cryptic Parse error | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-242281@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9398
Author: Girgias
### Description
This issue is most notable with the `
array` keyword as it is also a built-in type name.
Indeed trying to alias `int`:
```php
<?php
use int as I;
```
Parses just fine (however it is impossible to actually use I as a type declaration as you would get
the following error `Fatal error: Cannot use 'int' as class name as it is reserved
in /in/nNOgL on line 5` (see https://3v4l.org/nNOgL)
which is its own mess that we might want to catch early)
However, with `array` (https://3v4l.org/fWrTK):
```php
<?php
use array as a;
```
We get the following error message:
```
Parse error: syntax error, unexpected token "array" in /in/F6SlE on line 3
```
I don't even know if this is actually fixable as this seems like some parser shenanigans.
### PHP Version
PHP 8.0.22 - master
### Operating System
_No response_