Skip to content

Editorial: Define length of built-in accessor functions#3770

Draft
nicolo-ribaudo wants to merge 1 commit intotc39:mainfrom
nicolo-ribaudo:length-accessor-functions
Draft

Editorial: Define length of built-in accessor functions#3770
nicolo-ribaudo wants to merge 1 commit intotc39:mainfrom
nicolo-ribaudo:length-accessor-functions

Conversation

@nicolo-ribaudo
Copy link
Copy Markdown
Member

Fixes #3762. Marking as "normative" because it specifies something that was not previously specified.

Marking as draft because Ecmarkup does not recognize this syntax.

At some point we might want to <dfn> "accessor function", since it's used in a bunch of place.

@nicolo-ribaudo nicolo-ribaudo added normative change Affects behavior required to correctly evaluate some ECMAScript source text spec bug labels Mar 18, 2026
@github-actions
Copy link
Copy Markdown

The rendered spec for this PR is available as a single page at https://tc39.es/ecma262/pr/3770 and as multiple pages at https://tc39.es/ecma262/pr/3770/multipage .

@ljharb
Copy link
Copy Markdown
Member

ljharb commented Mar 18, 2026

I don’t agree it wasn’t already specific - it just wasn’t explicit or consistent. Getters take no arguments and setters take one, so their lengths must have always been 0 and 1 respectively.

<p>Built-in function objects that are not constructors do not have a *"prototype"* property unless otherwise specified in the description of a particular function.</p>
<p>Each built-in function defined in this specification is created by calling the CreateBuiltinFunction abstract operation (<emu-xref href="#sec-createbuiltinfunction"></emu-xref>). The values of the _length_ and _name_ parameters are the initial values of the *"length"* and *"name"* properties as discussed below. The values of the _prefix_ parameter are similarly discussed below.</p>
<p>Every built-in function object, including constructors, has a *"length"* property whose value is a non-negative integral Number. Unless otherwise specified, this value is the number of required parameters shown in the subclause heading for the function description. Optional parameters and rest parameters are not included in the parameter count.</p>
<p>Every built-in function object, including constructors, has a *"length"* property whose value is a non-negative integral Number. Unless otherwise specified, this value is the number of required parameters shown in the subclause heading for the function description. Optional parameters and rest parameters are not included in the parameter count. For built-in get accessor functions the value is always *+0*<sub>𝔽</sub>. For built-in set accessor functions the value is always *1*<sub>𝔽</sub>.</p>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
<p>Every built-in function object, including constructors, has a *"length"* property whose value is a non-negative integral Number. Unless otherwise specified, this value is the number of required parameters shown in the subclause heading for the function description. Optional parameters and rest parameters are not included in the parameter count. For built-in get accessor functions the value is always *+0*<sub>𝔽</sub>. For built-in set accessor functions the value is always *1*<sub>𝔽</sub>.</p>
<p>Every built-in function object, including constructors, has a *"length"* property whose value is a non-negative integral Number. Unless otherwise specified, this value is the number of required parameters shown in the parameter list in the subclause heading for the function description. Optional parameters and rest parameters are not included in the parameter count. For built-in get accessor functions, the value is always *+0*<sub>𝔽</sub>. For built-in set accessor functions, the value is always *1*<sub>𝔽</sub>.</p>

Copy link
Copy Markdown
Member

@michaelficarra michaelficarra left a comment

Choose a reason for hiding this comment

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

otherwise LGTM

@nicolo-ribaudo nicolo-ribaudo changed the title Normative: Define length of built-in accessor functions Editorial: Define length of built-in accessor functions Mar 23, 2026
@nicolo-ribaudo nicolo-ribaudo added editorial change and removed normative change Affects behavior required to correctly evaluate some ECMAScript source text spec bug labels Mar 23, 2026
@bakkot
Copy link
Copy Markdown
Member

bakkot commented Mar 23, 2026

If you're adding parentheses to the get/set H1s, you probably want to update tc39/ecmarkup#676 to strip out the parameter list from the generated function name for accessors (but you'll need to anyway because the linter doesn't expect names of that form).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Length of built-in accessor functions is not defined

4 participants