Skip to content

array_splice on a copy of an int-valued string-keyed array with string replacements throws TypeError #428

Closed

Description

@blacktrs

Summary

array_splice on a copy of an int-valued string-keyed array with string replacements throws TypeError.

Repro

<?php
function main(): void {
    $assoc = [];
    foreach (['k0', 'k1', 'k2', 'k3', 'k4', 'k5'] as $i => $k) { $assoc[$k] = $i; }
    $a = $assoc;
    $r = array_splice($a, 2, 2, ['a', 'b']);
    echo json_encode($a), json_encode($r), "\n";
}
main();

Expected (php)

{"k0":0,"k1":1,"0":"a","1":"b","k4":4,"k5":5}{"k2":2,"k3":3}

Actual (manticore 5833db53, Darwin arm64)


[exit code 255]
PHP Fatal error:  Uncaught TypeError: Argument must be of type int, string given

Tracking

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

Activity

  1. added
    bug
    wrong-answer
    on Oct 24, 2026
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