Bug #51715 [Opn]: Lambda's definition breaks references when using use() clause.

From: Date: Sat, 01 May 2010 11:30:20 +0000
Subject: Bug #51715 [Opn]: Lambda's definition breaks references when using use() clause.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-150078@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=51715&edit=1 ID: 51715 User updated by: ninzya at inbox dot lv Reported by: ninzya at inbox dot lv Summary: Lambda's definition breaks references when using use() clause. Status: Open Type: Bug Package: Scripting Engine problem Operating System: Any PHP Version: 5.3.2 New Comment: If you change lambda definition from function() use( $y){}; to function() use( &$y){}; then script outputs expected result: [...]# cat test.php <?php $x =null; // reference $x $y =&$x; // focus on this (lambda def.) function() use( &$y){}; // update value of $x via reference. $y =10; // No bug, since ref. was not broken var_dump( $x); ?> [...]# php -v PHP 5.3.2 (cli) (built: Mar 4 2010 22:12:20) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies [...]# php test.php int(10) Previous Comments: ------------------------------------------------------------------------ [2010-05-01 13:27:26] ninzya at inbox dot lv Description: ------------ See test script. Test script: --------------- [...]# cat test.php <?php $x =null; // reference $x $y =&$x; // focus on this (lambda def.) function() use( $y){}; // update value of $x via reference. $y =10; // oops, bug, outputs NULL since lambda def. breaks // the reference. var_dump( $x); ?> [...]# php -v PHP 5.3.2 (cli) (built: Mar 4 2010 22:12:20) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies [...]# php test.php NULL Expected result: ---------------- int(10) Actual result: -------------- NULL ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=51715&edit=1

« previous php.bugs (#150078) next »