This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 25630 - "The following use of overloading however is inv..."
Summary: "The following use of overloading however is inv..."
Status: RESOLVED DUPLICATE of bug 23879
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: WebIDL (show other bugs)
Version: unspecified
Hardware: All All
: P2 minor
Target Milestone: ---
Assignee: Cameron McCormack
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-09 08:15 UTC by Nils Barth
Modified: 2017-07-28 14:41 UTC (History)
4 users (show)

See Also:


Attachments

Description Nils Barth 2014-05-09 08:15:00 UTC
http://heycam.github.io/webidl/#idl-overloading

This is outdated:

[[
The following use of overloading however is invalid:

IDL
interface B {
  void f(DOMString x);
  void f(float x);
};
since DOMString and float are not distinguishable.
]]

...since DOMStrings and floats (numerics) are now distinguishable.

This can be corrected by replacing "DOMString" with "long":

[[
The following use of overloading however is invalid:

IDL
interface B {
  void f(long x);
  void f(float x);
};
since long and float are not distinguishable.
]]
Comment 1 Anne 2014-05-12 09:02:10 UTC
I think it's still invalid to accept both string and number because it's unclear whether you should use ToString or ToNumber.
Comment 2 Nils Barth 2014-05-12 09:19:22 UTC
AFAICT, String vs. Number is handled in the overload resolution algorithm
(nutshell: if argument is a Number, resolve to numeric if possible;
otherwise use ToString if possible,
otherwise use ToNumber if possible)
http://heycam.github.io/webidl/#dfn-overload-resolution-algorithm

In detail:
10. Otherwise: if V is a Number value, and there is an entry in S that has one of the following types at position i of its type list,
• a numeric type
...

11. Otherwise: if there is an entry in S that has one of the following types at position i of its type list,
• DOMString
...

12. Otherwise: if there is an entry in S that has one of the following types at position i of its type list,
• a numeric type
...
Comment 3 Tobie Langel 2017-07-28 14:41:06 UTC

*** This bug has been marked as a duplicate of bug 23879 ***