Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distinguishability of nullable types and dictionaries seems broken #190

Closed
bzbarsky opened this issue Oct 17, 2016 · 3 comments
Closed

Distinguishability of nullable types and dictionaries seems broken #190

bzbarsky opened this issue Oct 17, 2016 · 3 comments

Comments

@bzbarsky
Copy link
Collaborator

Consider this IDL:

void foo(DOMString? arg);
void foo(optional SomeDictionaryType arg);

Is this valid? I believe it shouldn't be. DOMString? and SomeDictionaryType should not be distinguishable. But as the spec stands right now, we have:

Two types are distinguishable if at most one of the two includes a nullable type and at least one of the following three conditions is true:

In this case, the first of the three conditions is true, since DOMString and SomeDictionaryType are distinguishable. Looking at the definition of "includes a nullable type" we have:

A type includes a nullable type if:
the type is a nullable type, or
the type is a union type and its number of nullable member types is 1.

In this case neither type is a union type. The definition of "nullable type" is:

A nullable type is an IDL type constructed from an existing type (called the inner type), which just allows the additional value null to be a member of its set of values. Nullable types are represented in IDL by placing a U+003F QUESTION MARK ("?") character after an existing type.

so only DOMString? is a nullable type and the two types are specced distinguishable.

This used to not be broken. For example, https://web.archive.org/web/20160801174701/https://heycam.github.io/webidl/ says:

Two types are distinguishable if at most one of the two includes a nullable type or is a dictionary type, and at least one of the following three conditions is true:

which makes these two types not distinguishable, since both are either nullable or dictionary....

@bzbarsky
Copy link
Collaborator Author

@tobie, @jyasskin, @domenic Oh, this got broken by #180 which removed the relevant important bit from the definition of "distinguishable"....

God, I wish we had unit tests for this spec. :(

@jyasskin
Copy link
Member

Oh, wow, you parsed "at most one of the two includes a nullable type or is a dictionary type" differently than I did. You did «"includes a nullable type or is a dictionary type" is true of at most one of the two», while I did «at most one of the two includes a nullable type and at most one of the two is a dictionary type». I'll send you a patch.

@bzbarsky
Copy link
Collaborator Author

Yeah, I agree the original wording could have been clearer.....

tobie added a commit to tobie/webidl that referenced this issue Oct 17, 2016
Fix distinguishable algorithm. Closes whatwg#190.
Fix record handling in various algorithms. Closes whatwg#191, closes whatwg#189
tobie added a commit to tobie/webidl that referenced this issue Oct 17, 2016
Fix distinguishable algorithm. Closes whatwg#190.
Fix record handling in various algorithms. Closes whatwg#191, closes whatwg#189
tobie added a commit to tobie/webidl that referenced this issue Oct 17, 2016
Fix distinguishable algorithm. Closes whatwg#190.
Fix record handling in various algorithms. Closes whatwg#191, closes whatwg#189.
tobie added a commit that referenced this issue Oct 18, 2016
Fix distinguishable algorithm. Closes #190.
Fix record handling in various algorithms. Closes #191, closes #189.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants