Skip to content

A property set hook is skipped when the receiver's static type is not exactly the class (a union-typed return). #448

Closed

Description

@blacktrs

Summary

A property set hook is skipped when the receiver's static type is not exactly the class (a union-typed return).

Repro

<?php
class A
{
    public int $x { get => 1; set { throw new Error('set hook ran: ' . $value); } }
}

function make(): A|false
{
    return new A();
}

$a = make();
try {
    $a->x = 5;
    echo "no error\n";
} catch (Error $e) {
    echo $e->getMessage(), "\n";
}
$b = [new A()][0];
try {
    $b->x = 6;
    echo "no error\n";
} catch (Error $e) {
    echo $e->getMessage(), "\n";
}

Expected (php)

set hook ran: 5
set hook ran: 6

Actual (manticore 7c330c5a, Darwin arm64)

no error
set hook ran: 6

Tracking

Known-bug repro: tests/aot/repro/wrong/hook_set_erased_receiver.php — bash tests/aot/xfail.sh -k hook_set_erased_receiver 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