Open ostrolucky opened 4 years ago
I found these snippets:
This should ideally not be an error, Psalm should retype such empty collection to first non-empty value.
Collections are just a generic classes to Psalm. Altering the type based on calls to some random method seems far-fetched, unless the method has @psalm-assert
docblock.
The message could be improved for sure. I have yet to see where inferred empty
could be useful in the context of template params, so maybe it may make sense to flag that immediately, not deferring the issue to the first call.
Why do you say random method? Psalm should know which methods are mutating TKey and T.
Details in https://github.com/vimeo/psalm/issues/3436, but I'll repost reproducer here https://psalm.dev/r/be559962d4.
This should ideally not be an error, Psalm should retype such empty collection to first non-empty value. Second best scenario, message should be definitely improved, normal user has no chance to understand how to fix code with such message.