Bug 158321 - [WebIDL] 'undefined' should be an acceptable value for nullable parameters
Summary: [WebIDL] 'undefined' should be an acceptable value for nullable parameters
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Bindings (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL: https://heycam.github.io/webidl/#es-n...
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-02 15:31 PDT by Chris Dumez
Modified: 2016-06-04 10:17 PDT (History)
7 users (show)

See Also:


Attachments
Patch (6.53 KB, patch)
2016-06-02 15:33 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (9.44 KB, patch)
2016-06-02 15:58 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2016-06-02 15:31:57 PDT
'undefined' should be an acceptable value for nullable parameters (and should be converted to null):
https://heycam.github.io/webidl/#es-nullable-type

Our bindings get most of the cases right but there is a bug in our overload resolution code.
Comment 1 Chris Dumez 2016-06-02 15:33:25 PDT
Created attachment 280372 [details]
Patch
Comment 2 Chris Dumez 2016-06-02 15:58:16 PDT
Created attachment 280377 [details]
Patch
Comment 3 Chris Dumez 2016-06-02 16:44:11 PDT
Comment on attachment 280377 [details]
Patch

Clearing flags on attachment: 280377

Committed r201627: <http://trac.webkit.org/changeset/201627>
Comment 4 Chris Dumez 2016-06-02 16:44:15 PDT
All reviewed patches have been landed.  Closing bug.
Comment 5 Darin Adler 2016-06-03 19:41:23 PDT
Comment on attachment 280377 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=280377&action=review

> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:1691
>              $condition .= "${value}.isUndefined() || " if $parameter->isOptional;
>  
> -            # FIXME: WebIDL says that undefined is also acceptable for nullable parameters and should be converted to null:
>              # http://heycam.github.io/webidl/#es-nullable-type
> -            $condition .= "${value}.isNull() || " if $parameter->isNullable;
> +            $condition .= "${value}.isUndefinedOrNull() || " if $parameter->isNullable;

This doesn’t seem optimal for parameters that are both optional and nullable.

Also, I don’t think we need to keep the URL to the current draft of WebIDL here.
Comment 6 Chris Dumez 2016-06-04 10:17:06 PDT
(In reply to comment #5)
> Comment on attachment 280377 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=280377&action=review
> 
> > Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:1691
> >              $condition .= "${value}.isUndefined() || " if $parameter->isOptional;
> >  
> > -            # FIXME: WebIDL says that undefined is also acceptable for nullable parameters and should be converted to null:
> >              # http://heycam.github.io/webidl/#es-nullable-type
> > -            $condition .= "${value}.isNull() || " if $parameter->isNullable;
> > +            $condition .= "${value}.isUndefinedOrNull() || " if $parameter->isNullable;
> 
> This doesn’t seem optimal for parameters that are both optional and nullable.
> 
> Also, I don’t think we need to keep the URL to the current draft of WebIDL
> here.

Ok, -> https://bugs.webkit.org/show_bug.cgi?id=158380