Skip to content

A method call on a null ?Map receiver does not throw "Call to a member function on null" (fused callback returns the seed, plain call dereferences null). #148

Closed

Description

@blacktrs

Summary

A method call on a null ?Map receiver does not throw "Call to a member function on null" (fused callback returns the seed, plain call dereferences null).

Repro

<?php
use Manticore\Ds\Map;

function fused(?Map $m): void
{
    try { var_dump($m->reduce(fn($c, $v) => $c + $v, 7)); }
    catch (Error $e) { echo get_class($e), ': ', $e->getMessage(), "\n"; }
}

function plain(?Map $m): void
{
    try { var_dump($m->count()); }
    catch (Error $e) { echo get_class($e), ': ', $e->getMessage(), "\n"; }
}

fused(null);
plain(null);

Expected (php)

Error: Call to a member function reduce() on null
Error: Call to a member function count() on null

Actual (manticore a74de197, Darwin arm64)


[exit code 139 — SIGSEGV]

Tracking

Known-bug repro: tests/aot/repro/wrong/ds_null_receiver_method_call.php — bash tests/aot/xfail.sh -k ds_null_receiver_method_call 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 8, 2026
  2. added 2 commits that reference this issue on Oct 8, 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