[php-src] Issue #7821: Can't use inherited constant value via 'self' in enum case value
| From: | nikic | Date: | Thu, 23 Dec 2021 20:00:43 +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-238556@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/7821
Comment Author: nikic
The problem here is that we compute a value to case table during compilation and all values must be
known at that time. This happens pre-inheritance, so
self::DEFAULT_VALUE is unknown at
the time. This is unfortunate from a language design perspective, because what exactly can be
evaluated during compilation and what can't is essentially an implementation detail (and may
depend on whether opcache is used or not).
I think it should be possible to make this part of inheritance instead, which should allow us to
evaluate all expressions. It would also delay some error reporting (about duplicate case values) to
that point.