Open Bug 1893492 Opened 1 year ago Updated 5 months ago

Function.prototype.toString should print set / get for accessor properties

Categories

(Core :: JavaScript: Standard Library, defect, P3)

defect

Tracking

()

People

(Reporter: twisniewski, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: parity-chrome, parity-safari)

Attachments

(1 file)

WebKit just addressed this in this commit, citing https://tc39.es/ecma262/#sec-function.prototype.tostring

For instance, try Object.getOwnPropertyDescriptor(Map.prototype, "size").get.toString().
In Firefox:

function size() {
    [native code]
}

In WebKit 193:

function get size() {
    [native code]
}

https://github.com/tc39/ecma262/pull/1948

We currently skip the get or set prefix explicitly. Just not doing that seems to be sufficient to fix this?

(In reply to Jan de Mooij [:jandem] from comment #1)

https://github.com/tc39/ecma262/pull/1948

We currently skip the get or set prefix explicitly. Just not doing that seems to be sufficient to fix this?

The spec doesn't actually require that the accessor prefix is part of the output:

Optionally, set F.[[InitialName]] to name.

Severity: -- → S3
Priority: -- → P3

It looks Safari ran into repeated web compat problems by shipping this change: https://github.com/tc39/ecma262/issues/3652.

It seems like we're currently compatible with the spec (setting the prefix is optional), but it sounds like the spec may change to require setting the prefix (possibly with the exception of a list of accessors provided in Annex B).

Given the problems Safari encountered, we should be careful about making changes here. On the TC39 call, Safari indicated it took 6 months for them to get broken site reports.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: