Skip to content

Intl: format and compare should be getter accessors, not data properties #604

@frostney

Description

@frostney

Summary

Per ECMA-402, `Intl.NumberFormat.prototype.format`, `Intl.DateTimeFormat.prototype.format`, and `Intl.Collator.prototype.compare` should be accessor properties (getters that return a bound function) rather than data properties.

Why

~20 intl402 test262 tests check `Object.getOwnPropertyDescriptor(...).get` on these properties.

Current behavior

```js
const desc = Object.getOwnPropertyDescriptor(Intl.NumberFormat.prototype, "format");
desc.get // undefined (not an accessor)
typeof desc.value // "function" (data property)
```

Expected behavior

```js
const desc = Object.getOwnPropertyDescriptor(Intl.NumberFormat.prototype, "format");
typeof desc.get // "function" (accessor)
desc.value // undefined
```

Scope notes

Collator already has a bound-compare approach on instances. The spec says the getter returns a bound function cached on the instance. Use `DefineProperty` with `TGocciaPropertyDescriptorAccessor` on the prototype, and have the getter lazily create and cache the bound function on the instance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    engineTGocciaEngine: language semantics, ECMAScript built-ins, parser, interpreter, bytecode VM

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions