On Wed, Mar 15, 2017 at 3:53 PM, Sara Golemon <poll...@php.net> wrote:
> On Wed, Mar 15, 2017 at 5:36 AM, Nikita Popov <nikita....@gmail.com> > wrote: > > Yes, this should behave as C. See also https://bugs.php.net/bug.php? > id=69676 > > for an existing bug report on the topic. > > > Given that bug is assigned to you, I'll just leave it in your hands then? > > > I think in 7.1 it might be even fairly simple so fix this: IIRC we now > store > > the defining CE on inherited constants, so we should know the scope to > > resolve against. > > > Even in 7.0 you could rewrite unresolved self:: references to the > current classname.Not as clean when it comes to producing error > messages, but certainly a quick and easy fix for the case where the > userspace code isn't broken. > > I had initially been thinking multi-pass, but there are some pretty > easy edge cases to fall into there... Fixed in 7.1 by https://github.com/php/php-src/commit/2bba4a0d7f6d5e5712d60bc1cf2119622d837e55 . I personally don't consider a PHP 7.0 backport worthwhile, as this is a long standing issue (from early PHP 5 days) and the fix will probably be hacky on 7.0. Note that CT resolving self:: doesn't quite cut it, because you also have to deal with parent::, which the compiler currently does not track. An alternative would be to force a full constant update on any parent CE, to ensure they will be evaluated in the correct order. Of course, this has other side effects, because it changes the point in time at which a certain constant is updated. Regards, Nikita