Edit report at https://bugs.php.net/bug.php?id=55673&edit=1

 ID:                 55673
 Updated by:         larue...@php.net
 Reported by:        der...@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:

OOPS!, I must lost my mind, what I was doing is erease NOP opline(god know How 
can I read this bug as "REMOVE UNUSED NOP" opline)....

sorry, but maybe this patch is also a litte useful...


Previous Comments:
------------------------------------------------------------------------
[2011-09-14 15:10:14] larue...@php.net

I have made a patch for this, and make whole test after patched. made sure that 
there is no new test failed after patched.
TEST RESULT:
trunk: http://pastebin.com/gMYc2Fp5
5.4branch: http://pastebin.com/7EePEE43
5.3branch: http://pastebin.com/m4wirXjr

------------------------------------------------------------------------
[2011-09-14 15:07:01] larue...@php.net

The following patch has been added/updated:

Patch Name: bug55673.diff
Revision:   1316012821
URL:        
https://bugs.php.net/patch-display.php?bug=55673&patch=bug55673.diff&revision=1316012821

------------------------------------------------------------------------
[2011-09-14 14:37:02] larue...@php.net

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.

------------------------------------------------------------------------
[2011-09-12 13:47:48] der...@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

Reply via email to