Bug #55372 [Ver->Csd]: Trait fails when method parameter has a default
| From: | gron@php.net | Date: | Mon, 15 Aug 2011 09:55:13 +0000 |
| Subject: | Bug #55372 [Ver->Csd]: Trait fails when method parameter has a default | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-162595@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55372&edit=1
ID: 55372
Updated by: gron@php.net
Reported by: slowlychillin at yahoo dot com
Summary: Trait fails when method parameter has a default
-Status: Verified
+Status: Closed
Type: Bug
Package: Class/Object related
Operating System: Windows 7
PHP Version: 5.4.0alpha3
Assigned To: gron
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.
Fixed per SVN rev 314933.
Previous Comments:
------------------------------------------------------------------------
[2011-08-15 09:54:01] gron@php.net
Automatic comment from SVN on behalf of gron
Revision: http://svn.php.net/viewvc/?view=revision&revision=314933
Log: Fixed Bug #55372 Incorrect handling of literals led to memory corruption.
# Dmitry you might want to review this patch, since I split up zend_add_literal
# and added a version for post-pass_two() usage.
------------------------------------------------------------------------
[2011-08-08 03:44:13] slowlychillin at yahoo dot com
Apologies for not providing a better code snippet. Here's one you can try out of the box. When
I uncomment the IF block, the script will hang. But if I have it commented out, like in the example
below, the script works.
<?php
trait testTrait {
public function testMethod() {
//if (1) {
$letters1 = range('a', 'z', 1);
$letters2 = range('A', 'Z', 1);
var_dump($letters1);
var_dump($letters2);
//}
}
}
class foo {
use testTrait;
}
$x = new foo;
$x->testMethod();
?>
------------
The script works both ways in php 5.4.0alpha2. Let me know if you need any other feedback!
------------------------------------------------------------------------
[2011-08-05 23:36:34] felipe@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
I can't reproduce some problem.
<?php
trait example_trait {
public function example_method($example_paramter = 1) {
echo $example_paramter;
}
}
class foo {
use example_trait;
}
$x = new foo;
$x->example_method();
------------------------------------------------------------------------
[2011-08-05 22:20:42] slowlychillin at yahoo dot com
Description:
------------
My code that worked in php 5.4.0alpha2 is not working in 5.4.0alpha3. When I stripped down the code
to nail down exactly where things were going wrong, it turns out that I have a trait with a method
with a parameter that has a default. When I remove the default, the script works just fine. When the
default is there, I get this error message showing up in my browser (Firefox 5):
"The connection was reset
The connection to the server was reset while the page was loading."
Test script:
---------------
// This does not work:
trait example_trait {
public function example_method($example_paramter = 1) {
echo $example_paramter;
}
}
// This does work:
trait example_trait {
public function example_method($example_paramter) {
echo $example_paramter;
}
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55372&edit=1