Re: [heycam/webidl] Missing argument handling (#461)

The overload resolution algorithm applies to all operations, even if they are not overloaded. See [create an operation function](https://heycam.github.io/webidl/#dfn-create-operation-function) steps 3-4. "Overloaded operations" is different from the "overload" used here in the algorithm, which refers to an element in an [effective overload set](https://heycam.github.io/webidl/#dfn-effective-overload-set). In fact, a single, non-overloaded operation `void a(optional DOMString arg);` in fact will produce two entries in the effective overload set.

The other potential point of confusion is that the exact exception message thrown by browsers can be different and confusing. In Chrome for example, while

```js
document.createElement('canvas').getContext('2d').drawImage()
```

throws `TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': 3 arguments required, but only 0 present.`,

```js
document.createElement('canvas').getContext('2d').drawImage(new Image(), 0, 0, 0)
```

throws `TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': Valid arities are: [3, 5, 9], but 4 arguments provided.`. Spec-wise, they are thrown from the same step ([overload resolution algorithm](https://heycam.github.io/webidl/#dfn-overload-resolution-algorithm) step 4).

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/issues/461#issuecomment-336964074

Received on Monday, 16 October 2017 17:38:04 UTC