ecma262 icon indicating copy to clipboard operation
ecma262 copied to clipboard

Is `null[{ toString: () => { console.log('hit') } }]` supposed to hit the `console.log`?

Open bakkot opened this issue 3 years ago • 4 comments

https://github.com/tc39/ecma262/pull/2267 changed the sequencing of the RequireObjectCoercible-on-base / ToString-on-property for member assignments, like a[b] = c.

As I read the spec, it also changed the semantics for null[{ toString: () => { console.log('hit') } }], which by my reading is now supposed to print hit before throwing:

Of engines I have on hand, only ChakraCore implements this behavior.

cc @codehag

bakkot avatar Feb 10 '22 23:02 bakkot

We can also observe this behavior with our implementation ESMeta, which strictly follows the spec. Currently, spec and tests are diverged.

h2oche avatar Mar 20 '22 02:03 h2oche

Opened a couple of PRs on the test262 repo that fixes the corresponding tests on either case: preserve the new semantics or rollback to the old behaviour. PRs will be waiting for consensus on this.

Hopefully this reactivates the issue's discussion!

jedel1043 avatar May 06 '23 03:05 jedel1043

Is this actually the same issue as #3295?

ptomato avatar Apr 15 '24 19:04 ptomato

Related, but not identical - that issue is much older than this one, which was only introduced in https://github.com/tc39/ecma262/pull/2267 (I think).

That said, I think the same PR might fix this as well. I'll have to walk through it carefully to confirm.

bakkot avatar Apr 15 '24 19:04 bakkot