Impossible intersection types are not checked at compile time
Nobody has claimed this yet.
- Dominant language
- XML
- Stars
- 596
- Forks
- 890
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 55
Description
Description
The following code:
<?php
class Foo {}
class Bar {}
function test(Foo&Bar $arg): void {}
I use intersection type Foo&Bar for function argument.
Actually, there is no type that would be comparable to Foo&Bar. Therefore, Foo&Bar is equivalent to the type never.
If i use never in argument type, PHP Fatal Error will be thrown. But if i use Foo&Bar, no error will occur.
Resulted in this output:
Nothing
But I expected this output instead:
PHP Fatal error: Foo&Bar cannot be used as a parameter type
PHP Version
PHP 8.3.11
Operating System
Ubuntu 20.04
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Foo&Bar parameter example from the issue and compare it with the documented behavior of PHP intersection types and never. No documentation file or test is named; done should be a documented resolution of the reported compile-time behavior or a confirmed correction to the report.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100