Re: Bug #12596 Updated: Definition of array using constants in array doesn't work

From: Date: Tue, 07 Aug 2001 08:26:13 +0000
Subject: Re: Bug #12596 Updated: Definition of array using constants in array doesn't work
References: 1 2  Groups: php.dev 
Request: Send a blank email to php-dev+get-62382@lists.php.net to get a copy of this message
This is a bug. If it's not a bug in classes, it definitely is a bug in
the language scanner/parser.

It doesn't even issue a warning, it just happily crunches the code and
executes it. This is not the way a robust interpreter should behave.

Jan 

Bug Database wrote:
> ID: 12596
> Updated by: jeroen
> Reported By: jack@mobil.cz
> Old Status: Open
> Status: Feedback
> Bug Type: Class/Object related
> Operating System: Linux
> PHP Version: 4.0.5
> New Comment:
> 
> This isn't supposed to work (class-var initing is not allowed for non-scalar (for example
> array) values).
> 
> It is funny that it turns out to work this way, a parse-error would be better IMO.
> 
> But it is not a bug, changing status to feedback.
> 
> It is in the manual somewhere that this isn't allowed, try language -> classes and
> object
> 
> Previous Comments:
> ------------------------------------------------------------------------
> 
> [2001-08-06 09:41:56] jack@mobil.cz
> 
> The following piece of code doesn't work:
> 
> <?
>     define ('A', 20);
> 
>     class B
>     {
> 	var $a = array(A => 10);
>     }
> 
>     $b = new B();
>     var_dump($b);
> ?>
> 
> It produces:
> 
> object(b)(1) {
>   ["a"]=>
>   array(1) {
>     ["A"]=>
>     int(10)
>   }
> }
> 
> which is unexpected (at least for me).
> 
> ------------------------------------------------------------------------
> 
> 
> 
> ATTENTION! Do NOT reply to this email!
> To reply, use the web interface found at http://bugs.php.net/?id=12596&edit=2

-- 
Jan Fedak                                         mailto:jack@mobil.cz  
                Linux - the ultimate NT Service Pack.  


Thread (6 messages)

« previous php.dev (#62382) next »