[[Set]] and inherited readonly data properties
Allen Wirfs-Brock
allen at wirfs-brock.com
Wed Mar 26 11:48:43 PDT 2014
On Mar 26, 2014, at 11:24 AM, Jason Orendorff wrote:
> "use strict";
> function Pony() {}
> Object.freeze(Object.prototype);
> Pony.prototype.toString = function () { return "Pony"; };
>
> The last line here throws a TypeError in ES5 and ES6.* Can we change
> it? To me, it stands to reason that you should be able to freeze
> Object.prototype and not break your other code, as long as that code
> doesn't actually try to modify Object.prototype.
>
> This bit some Mozilla hackers in <http://bugzil.la/980752>.
>
> Compatibility: Changing from throwing to not-throwing is usually ok.
> In addition, I don't think Chrome implements this TypeError. So
> presumably the web can't be depending on the exception.
This change would not just eliminating a throw in strict mode. It is also change sloppy mode behavior where such assignments have been silently ignored since ES1. It would be a fundamental change to the meaning of the [[Writable]] property attribute.
see http://wiki.ecmascript.org/doku.php?id=strawman:fixing_override_mistake (and links from that page)
also see the recent discussion at https://github.com/getify/You-Dont-Know-JS/issues/91#issuecomment-38702332
So far we have not been able to reach a consensus on changing this. I don't know whether report actually adds any new information or whether it will help develop a consensus.
Allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140326/5c31e7cf/attachment.html>
More information about the es-discuss
mailing list