Re: [RFC] [Discussion] Bound-Erased Generic Types
| From: | Matthew Brown | Date: | Thu, 11 Jun 2026 13:37:30 +0000 |
| Subject: | Re: [RFC] [Discussion] Bound-Erased Generic Types | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-131206@lists.php.net to get a copy of this message | ||
On Tue, 9 Jun 2026 at 10:23, Rob Landers <rob@getswytch.com> wrote:
> I don't have enough time today to write out long responses to both your
> comments. But to this end, scalar inference requires deciding how to handle
> at the RFC level, not a POC level.
>
> new Box(42);
> new Box(42.0);
> new Box("42")
>
>
> In non-strict mode, are these all equivalent? What exactly is T's type
> here?
>
> Scalars in PHP ... are weird. I wasn't going to try to define it here.
>
> — Rob
>
Handling of this really does not have to be defined at the RFC level. It's
a typechecker implementation — and it's ok for them to differ.
This is a good post describing how the direct equivalent in Python is
treated differently by Python type checkers:
https://pyrefly.org/blog/container-inference-comparison/.
Best wishes,
Matt