Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98535 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37038 invoked from network); 15 Mar 2017 10:36:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Mar 2017 10:36:28 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.182 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.128.182 mail-wr0-f182.google.com Received: from [209.85.128.182] ([209.85.128.182:33463] helo=mail-wr0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3B/DD-38004-B2919C85 for ; Wed, 15 Mar 2017 05:36:27 -0500 Received: by mail-wr0-f182.google.com with SMTP id u48so7979757wrc.0 for ; Wed, 15 Mar 2017 03:36:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=ueiFii4TT1hOmEB2NyGqG4YMP31vIXtntiN6foEGu/I=; b=nnhueKlJi8zzc/cCzlvTSD+lCrzKTsRCk9fScN68XFfdOE/i7lh/gej6xxiadKjqOf Lnc0B9OuIxpI7p0eZStQ/oIeZvz+tJoVS7ONMSidlTGIAXkb7MWU6pYBoK838wQgKvcs qubRxv+LeOWgOG7uMDSGDPHoyAlI6xW5bLP1wdzS3h1Ga6NpEPqyePPs0dW/ULWNBb8w S/S8ucyl/5DUX8LKoRmRQbTmQBHhlEiTdxHPQCEgYyDSwEjWKBPK5fdF6QYxxVNQhWWL 5s1C8SFIiRWNfDU4qxPwJVn5bha2SKvCwTdTZT1QdleAWQHg0JxXXXXmoLEnvDRDOQbl 4vWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=ueiFii4TT1hOmEB2NyGqG4YMP31vIXtntiN6foEGu/I=; b=e3YtY5KtcEoADXJNPYCgTxRUGw02CPenzvMTqRbceOUUd2xd/565MzzC4bzh6RRw1g QOhFIQOjSWUxTKTbdPeYbD3zlWAbrmG0PQTBErHO2zwwGH9ExAHYTmxS4dyen8jtFnD8 FiYOpYdDdx++Eii5znxf5QRkKazpqRh7zxr71hjmqNm9xDay8s0LrurAoqe/4DtvL9PS Q+Don0P+FPoD2Qjgce87G/dCH+2wPR6ipi2YpKBYr05+KGh3v2jW2ZnYzJ8Q1UOz0VgI EJu/gT/P0QjSrAvED72ZuZ8uymWrH2pb5QB9W6qHxodPWFkx3OS8fw2Bq3EvU0NeMjXo vCCQ== X-Gm-Message-State: AFeK/H0cmybsWQ6Wa2J/n0HEqzNVo3UZSZDtIWvC0WLRMVGAu9e7bnwZfIUDkVjXod+jSB70FTLjKGUqG8WS8w== X-Received: by 10.223.176.143 with SMTP id i15mr2443708wra.136.1489574184536; Wed, 15 Mar 2017 03:36:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.170.216 with HTTP; Wed, 15 Mar 2017 03:36:24 -0700 (PDT) In-Reply-To: References: Date: Wed, 15 Mar 2017 11:36:24 +0100 Message-ID: To: Sara Golemon Cc: PHP internals Content-Type: multipart/alternative; boundary=001a1141b6a022cf6b054ac2844e Subject: Re: [PHP-DEV] Unexpected results from constant folding From: nikita.ppv@gmail.com (Nikita Popov) --001a1141b6a022cf6b054ac2844e Content-Type: text/plain; charset=UTF-8 On Wed, Mar 15, 2017 at 3:43 AM, Sara Golemon wrote: > This comes in thanks to my old friend Fred Emmott on the HHVM project: > https://3v4l.org/vUHq3 > > class Foo { > const A = 1 << 0; > const B = self::A | self::C; > const C = 1 << 1; > > } > > class Bar extends Foo { > const A = 1 << 2; > const C = 1 << 3; > } > > var_dump(decbin(Bar::B)); > // HHVM result: 11 > // PHP5 result: 1100 > // PHP7 result: 1001 > > HHVM's result is clearly correct as `self::` refers to the defining > class and so should bind to Foo's values for A and C. > PHP5's result is at least rationally viable, although it effectively > redefines `self::` to the semantics of `static::` just for this case. > PHP7's result is... well, I can imagine how it occurs, but it can't be > called correct by any measure. > > Opinions on the right thing to do here? > a) Leave it alone because it's been that way since 7.0 > b) Revert to php5 behavior > c) Match HHVM's behavior > > I vote C because that's the semantic meaning of self:: and we should > respect PHP's own language rules. > Barring that, I'd be okay with B as it's at least explainable without > too much mental gymnastics. > I straight up veto A. That's just cray-cray. > Yes, this should behave as C. See also https://bugs.php.net/bug.php?id=69676 for an existing bug report on the topic. 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. Nikita --001a1141b6a022cf6b054ac2844e--