[whatwg/webidl] Truncation in "convert a Web IDL arguments list to an ECMAScript arguments list" seems (potentially) incorrect (Issue #1377)

### What is the issue with the Web IDL Standard?

https://webidl.spec.whatwg.org/#web-idl-arguments-list-converting

> 1.  Let esArgs be an empty [list](https://infra.spec.whatwg.org/#list).
>     
> 2.  Let i be 0.
>     
> 3.  Let count be 0.
>     
> 4.  While i < args’s [size](https://infra.spec.whatwg.org/#list-size):
>     
>     1.  If args\[i\] is the special value “missing”, then [append](https://infra.spec.whatwg.org/#list-append) undefined to esArgs.
>         
>     2.  Otherwise, args\[i\] is an IDL value:
>         
>         1.  Let convertResult be the result of [converting](#dfn-convert-idl-to-ecmascript-value) args\[i\] to an ECMAScript value. Rethrow any exceptions.
>             
>         2.  [Append](https://infra.spec.whatwg.org/#list-append) convertResult to esArgs.
>             
>         3.  Set count to i + 1.
>             
>     3.  Set i to i + 1.
>         
> 5.  Truncate esArgs to contain count items.
>     
> 6.  Return esArgs.

As far as I can tell, *args* could be « value, "missing", optionalValue », in which case *count* would be 2 in step 5 and the output would be « value, undefined ». This seems incorrect.

If that case is impossible, the spec should say that. Otherwise I suppose it should count the number of trailing "missing" values in *args* separately.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/issues/1377
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/webidl/issues/1377@github.com>

Received on Tuesday, 12 December 2023 12:33:47 UTC