Skip to content

Regression: nested array-return builtin in call argument evaluates to null (ext/standard/array.c, streams.c) #9547

Description

@PurHur

Category

stdlib · compile lowering · php-src-strict

Problem

When a builtin that returns an array is used inline as an argument to another builtin, the nested expression evaluates to null instead of the returned array. Assigning the same call to a variable first works.

Affects array_keys(), array_values(), stream_get_filters(), and similar array-return builtins nested in in_array(), array_map(), etc.

php-src reference

Repro

test/repro/maintainer_gap_nested_array_builtin_arg.php:

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_gap_nested_array_builtin_arg.php
php bin/vm.php test/repro/maintainer_gap_nested_array_builtin_arg.php'
Call Zend VM (bug)
in_array('a', array_keys($src), true) true TypeError: haystack null
in_array('string.rot13', stream_get_filters(), true) true TypeError: haystack null
$k = array_keys($src); in_array('a', $k, true) (control) true true

Scope (PHP-in-PHP)

Area Path
VM call lowering nested FUNCCALL return slot must survive as callee argument
Compiler lib/Compiler.php / opcode emission for call-as-argument
Stdlib no C runtime workaround — fix expression evaluation

Distinct from #9390 (enum needle + inline haystack + literal strict mis-bind).

Done when (php-src-strict)

  • Repro matches Zend for nested array_keys and stream_get_filters
  • count(explode(...)) and other nested non-array returns stay green
  • Compliance guard under test/compliance/cases/stdlib/nested_array_builtin_arg.phpt

Links

North star #1492

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions