[heycam/webidl] FrozenArray: Is T mutable? (#348)

A FrozenArray\<T\> is said to be:

> A frozen array type is a parameterized type whose values are references to objects that hold a fixed length array of unmodifiable values. The values in the array are of type T.
> 
> Since FrozenArray\<T\> values are references, they are unlike sequence types, which are lists of values that are passed by value.

http://heycam.github.io/webidl/#idl-frozen-array

A fixed length value of unmodifiable values sounds like the values themselves are immutable. But the values are references, and the conversion from sequence does not freeze the elements of the array, only the array object:

> 1. Let array be the result of converting the sequence of values of type T to an ECMAScript value.
> 2. Perform SetIntegrityLevel(array, "frozen").
> 3. Return array.

http://heycam.github.io/webidl/#es-frozen-array

It is clear that `frozenArray.push(foo)` and `frozenArray[0] = 42` should have no effect, but what about `frozenArrayOfObjects[0].foo = "bar"`?

We should either:

- Clarify the FrozenArray description to say that the objects are mutable.
- Update the conversion algorithm to include `SetIntegrityLevel(array[i], "frozen")`.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/issues/348

Received on Monday, 24 April 2017 11:31:52 UTC