spec: Definition of materialization is insufficient
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 302
- Avg merge
- 23h
- Merged PRs (30d)
- 8
Description
The spec currently defines materialization as follows:
Given a gradual type A, if we replace zero or more occurrences of Any in A with some type (which can be different for each occurrence of Any), the resulting gradual type B is a materialization of A.
A type A is assignable to B if there exists a pair of materializations A' and B' of A and B such that A' is a subtype of B'.
Now let's consider whether list[int] | list[str] is assignable to list[Any]. To do so, we have to consider materializations of list[Any], created by substituting Any with some other type. But there's nothing we can substitute for Any that would make for a fully static type that is a supertype of list[int] | list[str], since list is invariant in its type parameter. Therefore, list[int] | list[str] is not assignable to list[Any]. Relatedly, this means list[Any] | list[Any] is not equivalent to list[Any]. This is obviously not a desirable conclusion; current type checkers treat list[int] | list[str] as assignable to list[Any], and they should.
I think to fix this, we could say that if A' and A'' are materializations of A, then the union A' | A'' must also be a materialization of A.
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 with the materialization definition in the linked typing specification and work through the list[int] | list[str] versus list[Any] example. Evaluate the proposed rule that unions of materializations remain materializations, including its effect on assignability and equivalence; done requires an agreed specification change and updated explanatory text.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100