Skip to content

Something weird. #8018

@rzvc

Description

@rzvc

Please rename this issue to something more appropriate, once you figure out what it is. I didn't know what to name it.

/**
* @psalm-type Test = string
*/
class Foo
{
    /** @var array<string, Test> */
	private array $stuff = [];
    
    /**
    * @param non-empty-list<string> $param
    * @return Test
    */
    public function foo(array $param)
    {
        $arr = &$this->stuff[$param[0]];	// This seems to cause Psalm to blackout.
        
        /** @var Test */
        $x = $arr;
        
        // This trace doesn't work, and $x's type appears to be mixed at this point.
        /** @psalm-trace $x */
        return $x;
    }
}

https://psalm.dev/r/f81173405a

Converting $param to string, works: https://psalm.dev/r/718c05c153
Same if we remove the reference on the offending line: https://psalm.dev/r/6ebda981ae

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions