Skip to content

An array parameter called with a typed array and with a json_decode result reads the decoded one as garbage. #189

Closed

Description

@blacktrs

Summary

An array parameter called with a typed array and with a json_decode result reads the decoded one as garbage.

Repro

<?php
function mk(): array { $r = []; $r["n"] = ["z" => null]; return $r; }
function f(array $c) { $c["n"]["enabled"] = false; var_dump($c["n"]); }
f(mk());
f(json_decode('{"n":{"z":null}}', true));

Expected (php)

array(2) {
  ["z"]=>
  NULL
  ["enabled"]=>
  bool(false)
}
array(2) {
  ["z"]=>
  NULL
  ["enabled"]=>
  bool(false)
}

Actual (manticore 30b33d1e, Darwin arm64)

array(2) {
  ["z"]=>
  NULL
  ["enabled"]=>
  bool(false)
}
float(2.169331616E-314)

Tracking

Known-bug repro: tests/aot/repro/wrong/erased_array_param_typed_and_decoded_callers.php — bash tests/aot/xfail.sh -k erased_array_param_typed_and_decoded_callers reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.

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

    bugwrong-answer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions