Skip to content

A class with a #[TypeDef] property makes any var_dump() in the program a compile error #106

Closed

Description

@blacktrs

Summary

A class with a #[TypeDef] property makes any var_dump() in the program a compile error.

Repro

<?php
#[TypeDef(repr: 'u16')]
final class Kind { public function __construct(public readonly int $value) {} }
final class W { public function __construct(public Kind $k) {} }
$w = new W(new Kind(7));
echo $w->k->value, "\n";
var_dump(1);

Expected (php)

7
int(1)

Actual (manticore 70a6c4b1, Darwin arm64)

compile failed (rc=65):
compile failed: #[TypeDef] Kind: argument 1 of `__mir_var_dump()` is `mixed` — boxing an erased value into a tagged cell loses the type, and everything downstream sees a bare number. Declare the parameter `Kind`, or pass `$x->value`
compile: front-end (parse/typeck/IR) returned null (rc=65)

Tracking

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