vimeo / vimeo/psalm

Type information lost when using reference

Open
#9,155 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

references
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.