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

Reduce the restrictions on members whose names match auto-generated properties #726

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
110 changes: 60 additions & 50 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -3981,12 +3981,12 @@ the iterator objects returned by <code class="idl">entries</code>,
<code class="idl">keys</code>, <code class="idl">values</code>, and {{@@iterator}} are
actual [=array iterator objects=].

Interfaces with iterable declarations must not
have any [=interface members=]
named "<code>entries</code>", "<code>forEach</code>",
"<code>keys</code>", or "<code>values</code>",
or have any [=inherited interfaces=]
that have [=members=] with these names.
Interfaces with iterable declarations and their [=inherited interfaces=] must not have any
[=regular operations=], [=regular attributes=] or [=constants=] named
"<code>entries</code>",
"<code>forEach</code>",
"<code>keys</code>", or
"<code>values</code>".

<div class="example">

Expand Down Expand Up @@ -4132,23 +4132,24 @@ keyword is used, this includes <code class="idl">entries</code>,
For read–write maplikes, it also includes <code class="idl">clear</code>,
<code class="idl">delete</code>, and <code class="idl">set</code> methods.

Maplike interfaces must not
have any [=interface members=]
named "<code>entries</code>", "<code>forEach</code>",
"<code>get</code>", "<code>has</code>",
"<code>keys</code>", "<code>size</code>", or
"<code>values</code>",
or have any [=inherited interfaces=]
that have [=members=] with these names.
Read–write maplike interfaces must not
have any [=attributes=]
or [=constants=] named
"<code>clear</code>", "<code>delete</code>",
or "<code>set</code>", or have any [=inherited interfaces=]
that have [=attributes=] or [=constants=] with these names.

Note: Operations named "<code>clear</code>", "<code>delete</code>",
or "<code>set</code>" are allowed on read–write maplike
Maplike interfaces and their [=inherited interfaces=] must not have any [=regular operations=],
[=regular attributes=] or [=constants=] named
"<code>entries</code>",
"<code>forEach</code>",
"<code>get</code>",
"<code>has</code>",
"<code>keys</code>",
"<code>size</code>", or
"<code>values</code>".

Read–write maplike interfaces must not have any [=regular attributes=] or [=constants=] named
"<code>clear</code>",
"<code>delete</code>", or
"<code>set</code>",
or have any [=inherited interfaces=] that have [=regular operations=], [=regular attributes=] or
[=constants=] with these names.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can interfaces inheriting from the read-write maplike have these things? Seems like they shouldn't...


Note: Operations with these names are allowed on read–write maplike
interfaces and will prevent the default implementation of these methods being
added to the interface prototype object in the ECMAScript language binding.
This allows the default behavior of these operations to be overridden.
Expand Down Expand Up @@ -4226,22 +4227,23 @@ keyword is used, this includes <code class="idl">entries</code>,
For read–write setlikes, it also includes <code class="idl">add</code>,
<code class="idl">clear</code>, and <code class="idl">delete</code> methods.

Setlike interfaces must not
have any [=interface members=]
named "<code>entries</code>", "<code>forEach</code>",
"<code>has</code>", "<code>keys</code>",
"<code>size</code>", or "<code>values</code>",
or have any [=inherited interfaces=]
that have [=members=] with these names.
Read–write setlike interfaces must not
have any [=attributes=]
or [=constants=] named
"<code>add</code>", "<code>clear</code>",
or "<code>delete</code>", or have any [=inherited interfaces=]
that have [=attributes=] or [=constants=] with these names.

Note: Operations named "<code>add</code>", "<code>clear</code>",
or "<code>delete</code>" are allowed on read–write setlike
Setlike interfaces and their [=inherited interfaces=] must not have any [=regular operations=],
[=regular attributes=] or [=constants=] named
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This forbids

interface A { void entries(); };
interface B : A { readonly setlike<long>; };

but not

interface A { readonly setlike<long>; };
interface B : A { void entries(); };

Should it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a really good question.... Seems like disallowing it until there's a use case that might want it, and then deciding how it should work, is reasonable...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

"<code>entries</code>",
"<code>forEach</code>",
"<code>has</code>",
"<code>keys</code>",
"<code>size</code>", or
"<code>values</code>".

Read–write setlike interfaces must not have any [=regular attributes=] or [=constants=] named
"<code>add</code>",
"<code>clear</code>", or
"<code>delete</code>",
or have any [=inherited interfaces=] that have [=regular operations=], [=regular attributes=] or
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, what about interfaces that inherit from the read-write setlike?

[=constants=] with these names.

Note: Operations with these names are allowed on read–write setlike
interfaces and will prevent the default implementation of these methods being
added to the interface prototype object in the ECMAScript language binding.
This allows the default behavior of these operations to be overridden.
Expand Down Expand Up @@ -11683,7 +11685,8 @@ property is the String value "<code>forEach</code>".

<h5 id="es-iterable-entries">entries</h5>

If the [=interface=] has an [=iterable declaration=],
If the [=interface=] does not declare a [=regular operation=] with [=identifier=]
<code class="idl">entries</code> and has an [=iterable declaration=],
then an <code class="idl">entries</code> data property must exist with attributes
{ \[[Writable]]: <emu-val>true</emu-val>, \[[Enumerable]]: <emu-val>true</emu-val>, \[[Configurable]]: <emu-val>true</emu-val> }
and whose value is a [=function object=].
Expand All @@ -11704,7 +11707,8 @@ the value of the {{@@iterator}} property.

<h5 id="es-iterable-keys">keys</h5>

If the [=interface=] has an [=iterable declaration=],
If the [=interface=] does not declare a [=regular operation=] with [=identifier=]
<code class="idl">keys</code> and has an [=iterable declaration=],
then a <code class="idl">keys</code> data property must exist with attributes
{ \[[Writable]]: <emu-val>true</emu-val>, \[[Enumerable]]: <emu-val>true</emu-val>, \[[Configurable]]: <emu-val>true</emu-val> }
and whose value is a [=function object=].
Expand Down Expand Up @@ -11745,8 +11749,8 @@ The value of the [=function object=]’s <code class="idl">name</code> property

<h5 id="es-iterable-values">values</h5>

If the [=interface=] has an
[=iterable declaration=],
If the [=interface=] does not declare a [=regular operation=] with [=identifier=]
<code class="idl">values</code> and has an [=iterable declaration=],
then a <code class="idl">values</code> data property must exist
with attributes { \[[Writable]]: <emu-val>true</emu-val>, \[[Enumerable]]: <emu-val>true</emu-val>, \[[Configurable]]: <emu-val>true</emu-val> }
and whose value is a [=function object=].
Expand Down Expand Up @@ -11919,7 +11923,8 @@ These additional properties are described in the sub-sections below.

<h5 id="es-map-size">size</h5>

There must exist a <code class="idl">size</code> property on
If |A| does not declare a [=regular attribute=] with [=identifier=]
<code class="idl">size</code>, there must exist a <code class="idl">size</code> property on
|A|’s [=interface prototype object=]
with the following characteristics:

Expand Down Expand Up @@ -11950,7 +11955,8 @@ with the following characteristics:

<h5 id="es-map-entries">entries</h5>

An <code class="idl">entries</code> data property must exist on
If |A| does not declare a [=regular operation=] with [=identifier=]
<code class="idl">entries</code>, there must exist an <code class="idl">entries</code> property on
|A|’s [=interface prototype object=]
with attributes { \[[Writable]]: <emu-val>true</emu-val>, \[[Enumerable]]: <emu-val>false</emu-val>, \[[Configurable]]: <emu-val>true</emu-val> }
and whose value is the [=function object=] that is the value of
Expand All @@ -11959,7 +11965,9 @@ the {{@@iterator}} property.

<h5 id="es-map-keys-values">keys and values</h5>

For both of <code class="idl">keys</code> and <code class="idl">values</code>, there must exist a data property with that name on
For both of <code class="idl">keys</code> and <code class="idl">values</code>,
if |A| does not declare a [=regular operation=] with that name as its [=identifier=],
there must exist a data property with that name on
|A|’s [=interface prototype object=]
with the following characteristics:

Expand All @@ -11973,7 +11981,9 @@ The value of the [=function object=]’s <code class="idl">name</code> property

<h5 id="es-map-get-has">get and has</h5>

For both of <code class="idl">get</code> and <code class="idl">has</code>, there must exist a data property with that name on
For both of <code class="idl">get</code> and <code class="idl">has</code>,
if |A| does not declare a [=regular operation=] with that name as its [=identifier=],
there must exist a data property with that name on
|A|’s [=interface prototype object=] with the following characteristics:

* The property has attributes
Expand Down Expand Up @@ -12007,7 +12017,7 @@ The value of the [=function object=]’s <code class="idl">name</code> property

<h5 id="es-map-clear">clear</h5>

If |A| does not declare a [=member=]
If |A| does not declare a [=regular operation=]
with identifier "<code>clear</code>", and
|A| was declared with a read–write maplike declaration,
then a <code class="idl">clear</code> data property with the following characteristics
Expand All @@ -12024,7 +12034,7 @@ The value of the [=function object=]’s <code class="idl">name</code> property

<h5 id="es-map-delete">delete</h5>

If |A| does not declare a [=member=]
If |A| does not declare a [=regular operation=]
with identifier "<code>delete</code>", and
|A| was declared with a read–write maplike declaration,
then a <code class="idl">delete</code> data property with the following characteristics
Expand Down Expand Up @@ -12059,7 +12069,7 @@ The value of the [=function object=]’s <code class="idl">name</code> property

<h5 id="es-map-set">set</h5>

If |A| does not declare a [=member=] with identifier "<code>set</code>",
If |A| does not declare a [=regular operation=] with identifier "<code>set</code>",
and |A| was declared with a read–write maplike declaration,
then a <code class="idl">set</code> data property with the following characteristics
must exist on |A|’s [=interface prototype object=]:
Expand Down