Bug #55673 [Asn]: Compiler creates (unused) compiled variables for self::$foo
| From: | laruence@php.net | Date: | Wed, 14 Sep 2011 14:37:02 +0000 |
| Subject: | Bug #55673 [Asn]: Compiler creates (unused) compiled variables for self::$foo | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-163534@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55673&edit=1
ID: 55673
Updated by: laruence@php.net
Reported by: derick@php.net
Summary: Compiler creates (unused) compiled variables for
self::$foo
Status: Assigned
Type: Bug
Package: Scripting Engine problem
Operating System: *
PHP Version: 5.3SVN-2011-09-12 (SVN)
Assigned To: dmitry
Block user comment: N
Private report: N
New Comment:
after a quick digging, I found this is caused by zend_do_early_binding, which make
the declare_class to NOP after use it.
I will try to make a patch for this.
Previous Comments:
------------------------------------------------------------------------
[2011-09-12 13:47:48] derick@php.net
Description:
------------
When having the following code:
<?php
class foo {
function bar() {
self::$bar = 42;
}
}
?>
The compiler generates compiled variable !0 for $bar, even though it's a class variable:
derick@whisky:/tmp$ php -dvld.active=1 -r 'class foo { function bar() { self::$bar = 42; }
}'
Finding entry points
Branch analysis from position: 0
Return found
filename: Command line code
function name: (null)
number of ops: 2
compiled vars: none
line # * op fetch ext return operands
---------------------------------------------------------------------------------
1 0 > NOP
1 > RETURN null
branch: # 0; line: 1- 1; sop: 0; eop: 1
path #1: 0,
Class foo:
Function bar:
Finding entry points
Branch analysis from position: 0
Return found
filename: Command line code
function name: bar
number of ops: 4
compiled vars: !0 = $bar
line # * op fetch ext return operands
---------------------------------------------------------------------------------
0 > ZEND_FETCH_CLASS 1
1 FETCH_W static member $1 'bar'
2 ASSIGN $1, 42
3 > RETURN null
branch: # 0; line: 1- 1; sop: 0; eop: 3
path #1: 0,
End of function bar.
End of class foo.
14:41 <@Derick> dmitry: I am wondering why self::$foo creates a compiled variable. Any idea?
14:42 <@Derick> dmitry: it creates it, but it's never used
14:44 <@dmitry> I see. It's probably because od simple one-pass compiler that first
interpret $foo as local variable and only then as a class variable :)
14:44 <@Derick> dmitry: any way we can fix that perhaps?
14:44 <@dmitry> Derick: could you please create a bug and assign it to me
14:44 <@Derick> yes, sure
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55673&edit=1