ID:               26760
 Updated by:       [EMAIL PROTECTED]
 Reported By:      eero at volotinen dot com
 Status:           Bogus
 Bug Type:         Unknown/Other Function
 Operating System: *
 PHP Version:      5.0.0RC1-dev
 New Comment:

Works ok here :)

it will leak memory (as it doesnt free the newly declared class).. but
since it fatal errors out anyway - it should be cleared  up on exit
?????

[EMAIL PROTECTED]:/tmp$ php5 -r 'if (1) {class a{const x=1;static function
f(){return
1;}}}else{class a{const x=0;static function f(){return 0;}}}echo
a::x.a::f()."\n";'
11
[EMAIL PROTECTED]:/tmp$ php5 -r 'if (0) {class a{const x=1;static function
f(){return
1;}}}else{class a{const x=0;static function f(){return 0;}}}echo
a::x.a::f()."\n";'
00



Previous Comments:
------------------------------------------------------------------------

[2004-01-05 09:24:42] [EMAIL PROTECTED]

The patch has a memleak and does not work correct. Please try the
following code:
php -r 'if (1) {class a{const x=1;static function f(){return
1;}}}else{class a{const x=0;static function f(){return 0;}}}echo
a::x.a::f()."\n";'
php -r 'if (0) {class a{const x=1;static function f(){return
1;}}}else{class a{const x=0;static function f(){return 0;}}}echo
a::x.a::f()."\n";'
Both print '00' but the first should obviously print '11'

------------------------------------------------------------------------

[2004-01-05 04:00:05] [EMAIL PROTECTED]

This appears to fix the nesting class without affecting conditional
definitions.


Index: zend_compile.c
===================================================================
RCS file: /repository/ZendEngine2/zend_compile.c,v
retrieving revision 1.507
diff -u -r1.507 zend_compile.c
--- zend_compile.c      3 Jan 2004 13:51:01 -0000       1.507
+++ zend_compile.c      5 Jan 2004 09:03:04 -0000
@@ -2315,6 +2315,11 @@
        int doing_inheritance = 0;
        zend_class_entry *new_class_entry =
emalloc(sizeof(zend_class_entry));
        char *lcname =
zend_str_tolower_dup(class_name->u.constant.value.str.val,
class_name->u.constant.value.str.len);
+       
+       if (CG(active_class_entry) != NULL) {
+               efree(lcname);
+               zend_error(E_COMPILE_ERROR, "Cannot use nest class definitions");
+       }
 
        if (!(strcmp(lcname, "self") && strcmp(lcname, "parent"))) {
                efree(lcname);
Index: zend_language_parser.y
===================================================================
RCS file: /repository/ZendEngine2/zend_language_parser.y,v
retrieving revision 1.132
diff -u -r1.132 zend_language_parser.y
--- zend_language_parser.y      27 Dec 2003 22:59:49 -0000      1.132
+++ zend_language_parser.y      5 Jan 2004 09:03:05 -0000
@@ -168,7 +168,9 @@
 
 inner_statement:
                statement
+       
        |       function_declaration_statement
+       |       class_declaration_statement             
 ;
 
 


------------------------------------------------------------------------

[2004-01-02 09:59:02] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

As Derick said.

------------------------------------------------------------------------

[2004-01-02 05:56:39] [EMAIL PROTECTED]

I don't think that anything is broken here. You just can't have a
conditional class definition (just like you can't instantiate a class
before it's declared anymore). 

------------------------------------------------------------------------

[2004-01-02 05:26:04] [EMAIL PROTECTED]

Changing title.

I suspect marcus's fix broke this.
http://news.php.net/article.php?group=php.zend-engine.cvs&article=2159

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/26760

-- 
Edit this bug report at http://bugs.php.net/?id=26760&edit=1

Reply via email to