Skip to content

Dictionary types being nullable doesn't make sense #967

Open
@tabatkins

Description

@tabatkins

Per https://heycam.github.io/webidl/#idl-nullable-type, dictionary types are allowed to be nullable (they're not excluded by any of the conditions), but unions containing dictionary types can't be nullable.

That is, MyDict? is valid, but (MyDict or DOMString)? is not.

This doesn't seem to make sense. Per https://heycam.github.io/webidl/#es-dictionary, JS null is always acceptable to convert to a dictionary type; nullability doesn't enter into the equation at all. In other words, dictionary types are implicitly nullable. You can also see this more easily in https://heycam.github.io/webidl/#es-union, where both null and undefined can be turned into a dictionary type if a union includes one.

Tracing the blame back, this change occurred in 6ac261b, with the reasoning given being "Disallow dictionaries from being nullable only as operation argument types.". But that edit preserved the fact that JS null is always convertable to a dictionary type, so I'm not sure what it was actually trying to do.

I suggest that we revert that change and just always disallow dictionary types from being nullable (since they're always implicitly nullable already).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions