Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98531 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15143 invoked from network); 15 Mar 2017 02:44:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Mar 2017 02:44:01 -0000 Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 74.125.82.52 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 74.125.82.52 mail-wm0-f52.google.com Received: from [74.125.82.52] ([74.125.82.52:38015] helo=mail-wm0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 99/DB-38004-D6AA8C85 for ; Tue, 14 Mar 2017 21:43:59 -0500 Received: by mail-wm0-f52.google.com with SMTP id t189so12624832wmt.1 for ; Tue, 14 Mar 2017 19:43:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:from:date:message-id:subject:to; bh=Q/K1ieLvMG4ER9c45BCbKLiI8WyOs/VfqM66oMN+zzI=; b=xbQF9HFPWv/QtTV935fPJrJKMOMm3LHdm7YWFAu4uSj70D8tpNRQT5T+hQ+1di9rSz 9K6C3zagTkLVhvXCxg7j+xrXcFz7NhfZla/VvI3Dd65Kahk1aUHG66kDO7Oo0+bDydDK 61Ehc6E1YlcvqlndaRkhn/x5P5564AwhFUQUQlkPOe+X+7P9g03TDabv3OM7ukTjEGPf KAM5R9w4I9vAtpFf85G8N2q0n4OEX0QMnd0WHH+zjmkmVq3aS8SG15sF0f+RiaAKNZJY SP9tBP3hVSmccywBKUc0Ow5K8ra2fBcpPfgG/q1Vxw1pK/ZJqe7/d4+sWTpl6uWa++14 mjCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to; bh=Q/K1ieLvMG4ER9c45BCbKLiI8WyOs/VfqM66oMN+zzI=; b=uPJlDrOfwepqTUdCgs+cFB1EMx1Zu02+akOo2QxsQ3OQ8BHHcG5Rv20f8Z4dfI6N/a dtWYuaPNWBeJT3D9dcJBaPkwkaGAHtwYS4dBwCbgv7BshjPzd5w1wyGoUbUAPw2knZEX 81sVbIFcGZH0K5A1QBicKBSyS0UWSGoPsfSvZ0gXlAgad55QhV0iwINxQ1Ux1NitWaZQ riuZBfyt3DkhC9+6NJVgqE5Z3Vl9qlz5RGMhYXwFxfHH59gnu85lpkXdUAnzAj35pvUK dtwwRHz3HR9c35OHCOvVBTCcE0JiJ4qd9MBmS1PdSDYAkJXQjLJ3/pSkpA2AGMYI3uFt osTg== X-Gm-Message-State: AFeK/H2qumthWX7Xbs275yT9aqupti/6ITDQVY9YD+DrHH6WKTJCdzYzl2J49zDOVfHg5f4mns2telbMsytLFw== X-Received: by 10.28.158.87 with SMTP id h84mr17428276wme.4.1489545835019; Tue, 14 Mar 2017 19:43:55 -0700 (PDT) MIME-Version: 1.0 Sender: php@golemon.com Received: by 10.223.152.213 with HTTP; Tue, 14 Mar 2017 19:43:54 -0700 (PDT) X-Originating-IP: [73.9.224.155] Date: Tue, 14 Mar 2017 21:43:54 -0500 X-Google-Sender-Auth: nkGSAUbu0CcW1S23g5Lr4mpKcCo Message-ID: To: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Unexpected results from constant folding From: pollita@php.net (Sara Golemon) 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. -Sara