Skip to content

Invalid issue arises when closure returns reference. #831

@tanzanite777

Description

@tanzanite777

Type: Bug

Code to illustrate:

$arr = [];
$ref =& $arr;

$fnBug = function&() use(&$ref) : array { return $ref; };

$tmp =& $fnBug(); // invalid issue: Only variables should be assigned by reference - PHP0445

$tmp[] = 1;
echo var_export($arr, true);

Extension version: 1.57.17031
VS Code version: Code 1.99.0 (4437686ffebaf200fa4a6e6e67f735f3edf24ada, 2025-04-02T21:35:19.530Z)
OS version: Windows_NT x64 10.0.19045
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz (8 x 3600)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 15.88GB (2.44GB free)
Process Argv --crash-reporter-id adf79977-8c83-4303-918e-a7dfc5f31bf1
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
binariesv615:30325510
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30959799
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dwnewjupyter:31046869
nativerepl2:31139839
pythonrstrctxt:31112756
nativeloc2:31192216
5fd0e150:31155592
dwcopilot:31170013
6074i472:31201624
dwoutputs:31242946
customenabled:31248079
hdaa2157:31222309
copilot_t_ci:31222730
850i5325:31264362
968h8231:31271074
jda6j935:31233686
pythoneinst12cf:31262606
bgtreat:31268568
fh1c7952:31258891
4gafe986:31271826
5b33h341:31253271
31787653:31262186
3e8i5726:31271747
49da9784:31264548

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions