Type information lost when using reference
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 5.9k
- Forks
- 708
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 25
Description
I have this array shape, and a function that can modify its values without modifying its type, and can do so for several different array shape that have the fields the function is modifying in common. When I pass an array shape to the function, its original type seems lost: https://psalm.dev/r/ebf182b2e6
Contributor guide
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 with the linked Psalm reproducer at https://psalm.dev/r/ebf182b2e6 and compare the inferred type before and after the array is passed by reference. Trace the type-inference behavior involved in that call and confirm that the original array shape is retained while the shared fields remain modifiable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100