dev_compiler icon indicating copy to clipboard operation
dev_compiler copied to clipboard

const list/map should be immutable

Open jmesserly opened this issue 10 years ago • 2 comments

https://codereview.chromium.org/1099333002 fixes canonicalization but not immutability for literals of those two types.

jmesserly avatar Apr 23 '15 15:04 jmesserly

we could use Object.freeze, that will protect the array from JS too

jmesserly avatar Apr 23 '15 15:04 jmesserly

I tired out freeze, the catch is we can't throw expandos on the object later (like hashCode). Weak maps are one alternative, another is just to precompute identityHashCode and such.

jmesserly avatar Jun 01 '15 22:06 jmesserly