[php-src] Issue #7821: Can't use inherited constant value via 'self' in enum case value
| From: | SerafimArts | Date: | Thu, 21 Apr 2022 13:17:28 +0000 |
| Subject: | [php-src] Issue #7821: Can't use inherited constant value via 'self' in enum case value | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-241122@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/7821
Comment Author: SerafimArts
Found another interesting feature-bug:
```php
class Example
{
final public const TEST = 42;
}
enum ExampleEnum: int
{
case CASE = Example::TEST;
}
```
1) If you run the code for the first time, then it works
2) If you run the code again (PHP 8.1.4), an error occurs:
Enum case value must be
compile-time evaluatable
There is a suspicion that this is somehow related to opcache:
```sh
php test.php -dopcache.jit_buffer_size=0 -dopcache.enable=1 -dopcache.enable_cli=0
// - First execution 42
// - Second execution 42
// - Third execution 42
php test.php -dopcache.jit_buffer_size=0 -dopcache.enable=1 -dopcache.enable_cli=1
// - First execution 42
// - Second execution: Enum case value must be compile-time evaluatable
// - Third execution: Enum case value must be compile-time evaluatable
```
P.S.
```
PHP 8.1.4 (cli) (built: Apr 4 2022 13:30:33) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.4, Copyright (c) Zend Technologies
with Zend OPcache v8.1.4, Copyright (c), by Zend Technologies
```