Skip to content

var_dump prints empty bodies for associative and sparse arrays #328

@nahime0

Description

@nahime0

Description

var_dump() reports the correct array count for non-list arrays, but drops every element from the printed body. The underlying array data still exists (count() and array_key_exists() keep working), so this looks like a debug/runtime formatting bug specific to associative and sparse arrays.

Steps to reproduce

<?php var_dump(["x" => 1]);

A second minimal variant shows the same bug for sparse integer keys:

<?php var_dump([2 => "b"]);

Expected behavior

PHP 8.4.19 prints the array entries, including their keys and values:

array(1) {
  ["x"]=>
  int(1)
}

and:

array(1) {
  [2]=>
  string(1) "b"
}

Actual behavior

Elephc prints an empty array body while still reporting the right element count:

array(1) {
}

Notes

The data itself appears to survive internally. This program still prints 1,yes under Elephc:

<?php $a = ["x" => 1]; echo count($a), ",", array_key_exists("x", $a) ? "yes" : "no";

Environment

  • Elephc commit: 02ffd63c0efdd8b5dd4069e0b6bd58dfe2a9325d
  • PHP: 8.4.19
  • OS: Darwin 25.5.0 arm64
  • Reproduced on: 2026-06-04T07:05:57Z

Metadata

Metadata

Assignees

No one assigned

    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