Closed Bug 1130744 Opened 9 years ago Closed 8 years ago

subclassing Array doesn't work

Categories

(Firefox Graveyard :: Shumway, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: till, Assigned: mbx)

References

Details

We do attempt to make it work to some extent, but it doesn't really. That's because there simply is no way to properly do it in pre-ES6 JS engines.

This is what breaks the Earley-Boyer v8 test, for example, but I'm sure that there is quite a bit of actual content that breaks because of it. I think we shouldn't even pretend to support it and throw instead, so that we don't debug issues that only show up way later.

In ES6 there are two different ways to achieve this: a bad one and a proper one.

The bad one is to use Proxies. The issue with subclassing Array is that it's impossible to implement the magic behavior of the .length property, which auto-updates when an array index-named property is set. With proxies, that is possible. It would also make these classes horrendously slow, so we shouldn't do it.

The proper way is to use ES6 classes, which allow subclassing builtins. That, however, currently works in exactly 0 engines. Once we have support for this in SpiderMonkey, we should use that.
Assignee: nobody → mbebenita
Blocks: shumway-m3
Blocks: shumway-1.0
No longer blocks: shumway-m3
Product: Firefox → Firefox Graveyard
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.