[whatwg/webidl] Suggestion: forbid ECMA-262/402-defined global names for some named constructs (Issue #1331)

There are two reasons I think it’d be good for Web IDL to specify something like the following rough attempt:

> A Web IDL construct which would imply defining properties of global objects in the ES binding whose property names are among those defined by ECMA-262 and ECMA-402 in [SetDefaultGlobalBindings](https://tc39.es/ecma262/#sec-setdefaultglobalbindings) is not valid.

1. The first reason is the obvious one — `interface Array {}` would be a bad time for everybody. But since that _is_ so obvious, it might seem weird to bother spilling ink on specifying that it shouldn’t be done.

2. The second reason is that the absence of the requirement means every time [define the global property references](https://webidl.spec.whatwg.org/#define-the-global-property-references) calls [CreateMethodProperty](https://tc39.es/ecma262/multipage/abstract-operations.html#sec-createmethodproperty), the assertion can be violated because some ES-defined global properties are unconfigurable. Given `interface _Infinity {}`, CreateMethodProperty’s `! DefinePropertyOrThrow` turns into a `? DefinePropertyOrThrow`.

---

I’m sure the requirement could be expressed other ways / better ways than my attempt above. I figured the abstract phrasing might be preferred for brevity, but here’s an attempt at explicitly enumerating the set of identifiers which I meant to cover there:

- identifiers of namespaces
- identifiers of interfaces not annotated by the [LegacyNoInterfaceObject] or [LegacyNamespace] extended attributes
- identifiers of callback interfaces which have const members
- identifiers of legacy factory function operations declared by [LegacyFactoryFunction] extended attributes
- identifiers declared as interface aliases by [LegacyWindowAlias] extended attributes
- identifiers of regular attributes of interfaces annotated by the [Global] extended attribute
- identifiers of regular operations of interfaces annotated by the [Global] extended attribute


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

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

Received on Sunday, 25 June 2023 23:45:29 UTC