This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 17560 - readonly binding unspecified for ECMAScript
Summary: readonly binding unspecified for ECMAScript
Status: RESOLVED WORKSFORME
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: WebIDL (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Cameron McCormack
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-20 20:39 UTC by Glenn Adams
Modified: 2012-06-20 21:39 UTC (History)
3 users (show)

See Also:


Attachments

Description Glenn Adams 2012-06-20 20:39:06 UTC
If it is intended that WebIDL readonly attribute keyword be mapped to the ECMAScript ReadOnly property attribute, then it should say so. Specifically, it should permit answering the question raised by what ECMAScript does for "It is language binding specific whether assignment is simply disallowed by the language, ignored or an exception is thrown."
Comment 1 Boris Zbarsky 2012-06-20 21:11:03 UTC
This is perfectly well defined http://dev.w3.org/2006/webapi/WebIDL/#es-attributes which says that the property descriptor looks like this:

  { [[Get]]: G, [[Set]]: S, [[Enumerable]]: true, [[Configurable]]: configurable }

where S is undefined if the attribute is readonly.

So when you're setting a readonly attribute, you end up in ECMA-262 section 8.12.5, call [[CanPut]] which lands you in 8.12.4, get to step 2, IsAccessorDescriptor returns true in step 2a, desc.[[Set]] is undefined, so [[CanPut]] returns false.  Back in [[Put]], this means that the set is silently ignored if "Throw" is false, otherwise a TypeError is thrown.

If you care to unwind some more, basically in strict mode TypeError is thrown an otherwise the set silently does nothing.

> mapped to the ECMAScript ReadOnly property attribute

There is no such thing.  There is a [[Writable]] property attribute, but it only applies to data descriptors, not accessor descriptors.  Setting it in an accessor descriptor is an error.
Comment 2 Glenn Adams 2012-06-20 21:39:47 UTC
(In reply to comment #1)
> This is perfectly well defined
> http://dev.w3.org/2006/webapi/WebIDL/#es-attributes which says that the
> property descriptor looks like this:

got it; thanks for deconstructing the flow; if i had searched for 'read only' instead of 'readonly' i would have found the paragraph at the end of 4.4.6:

"Note that attempting to assign to a property corresponding to a read only attribute ..."

> 
> > mapped to the ECMAScript ReadOnly property attribute
> 
> There is no such thing.

There is if one is reading EMCA-262 3rd Ed. Now that I see WebIDL references 5.1 Ed, I see that property attribute has been removed.