Skip to content

Make List[<nothing>] a subtype of List[X]? #6613

Closed
@JukkaL

Description

@JukkaL

We could probably treat List[<nothing>] as a subtype of List[X] without significant unsafety if we ensure that no variables will be inferred with List[<nothing>] types, and List[<nothing>] can't be used as a declared type. This was discussed elsewhere a while ago. With this restriction, you can't easily perform mutation operations on an empty list that would also be used as a value in another context, since all values are usually temporaries. (Yes it's easy enough to construct an example where this is still unsafe, but these seem very unlikely to happen in real code).

#6572 is an example that this could be useful, but this has come up in other contexts as well.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions