SpiderMonkey: r/o Error = 3 vs. var Error = 3;

I've made the Error constructor r/o to avoid users re-defining it
(JS_GetProperty w/ "Error" against global + JS_SetPropertyAttributes w/

This is executed in an ESContext which has a global object created by
JS_NewObject(jsc, class_with_no_constructor, NULL, NULL).
(class_with_no_constructor is essentially a static JSClass)

After which the standard classes are initialized against this global

The question is, why is it that executing "Error = 3" with the global
object as the scope results in no exception, whereas executing "var
Error = 3"  yield the following exception:

TypeError: redeclaration of const Error

? I would have assumed the opposite be true.  The result in both is
Error is not re-defined of course.

If the answer is read the ECMA spec go ahead and RTFM me :)

- Alex

6/7/2006 4:54:19 AM
mozilla.dev.tech.js-engine 2024 articles. 0 followers. Post Follow

2 Replies

Similar Articles

[PageSpeed] 12

I've traced it down to js_SetProperty and the following code:

        if ((attrs & JSPROP_READONLY) ||
            (SCOPE_IS_SEALED(scope) && pobj == obj)) {
            JS_UNLOCK_SCOPE(cx, scope);
            if ((attrs & JSPROP_READONLY) && JS_VERSION_IS_ECMA(cx))
                return JS_TRUE;
            goto read_only_error;

and it's going in because attrs & JSPROP_READONLY is true.

interestingly, it seems if the version isn't ECMA, it would throw an
exception, otherwise it just silently returns w/o setting the property
value...interesting...and not what I'd expect (w/o reading ECMA *g*).

ah, and I see in a newer rev of this file this behavior is further tied
to JS_HAS_STRICT_OPTION.   Apparently this is an ECMA oddity.

now to start ECMA grepping

6/7/2006 5:18:12 AM
interesting, per Brendan

> Readonly properties, when set by assignment, are not changed, but no error or exception is thrown.


I'm guessing that if I created a new object proto'd on my global, an
executed "var Error = 3"  it would not throw an exception.

why the behavior is different between these two cases is pretty odd

6/7/2006 5:33:50 AM

Similar Artilces:

superreview granted: [Bug 212231] Errors from document.open() cause silent failures in JS : [Attachment 127391] Don't return JS_FALSE in common cases to the JS engine w/o throwing an exception #3
Boris Zbarsky <bzbarsky@mit.edu> has granted Christopher A. Aillon <caillon@aillon.org>'s request for superreview: Bug 212231: Errors from document.open() cause silent failures in JS http://bugzilla.mozilla.org/show_bug.cgi?id=212231 Attachment 127391: Don't return JS_FALSE in common cases to the JS engine w/o throwing an exception http://bugzilla.mozilla.org/attachment.cgi?id=127391&action=edit ------- Additional Comments from Boris Zbarsky <bzbarsky@mit.edu> Dammit. I sr'ed this, then bugzilla clobbered it when caillon commented! ...

Overriding nsIHttpProtocolHandler with JS component, permissions errors in Firefox 3.0 and 3.5 not 3.6
I have an extension with a Javascript component which registers itself with the contract @mozilla.org/network/protocol;1?name=http and thus replaces the usual HTTP protocol handler. Most of the time it just passes method calls on to the default handler. I have run into trouble with the various "userAgent properties" of nsIHttpProtocolHandler. I tried just passing gets and sets on to the default handler, for example: get userAgent() { return savedHttpHandler.userAgent; }, get vendor() { return savedHttpHandler.vendor; }, set vendor(v) { savedHttpHandler.vendor...

after success update from 3.1.1 to 3.2, I test my site to update from 3.2 to 4.0, and I got this error
  Server Error in '/wpatest' Application. Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. Parser Error Message: Stream is not a valid resource file.Source Error: Line 1: <?xml version="1.0" encoding="UTF-8" ?> Line 2: <root> Line 3: <language name="English" key="en-US" fallback=""/>Source File: /wpatest/App_GlobalResources/Locales.xml.resources    Line: 1 Version Informatio...

3.2.3->3.4 error
Hello, Have followed upgrade instructions and check_setup reporting no problems, nor sanity check. Bugzilla sort of works until you try to do a query when you get: undef error - The 'name' parameter (undef) to DateTime::TimeZone::new was an 'undef', which is not one of the allowed types: scalar at /usr/local/share/perl/5.8.8/DateTime/TimeZone.pm line 32 DateTime::TimeZone::new('undef', 'name', 'undef') called at Bugzilla/User.pm line 369 Bugzilla::User::timezone('Bugzilla::User=HASH(0x940b728)') called at Bugzilla/Util.pm line ...

Upgrade Error 3.1 to 3.2.1
I upgraded my local test site from 3.1.1 to 3.2.1 with no problems.  I then upgraded my hosted site,  but am getting an error when I go to the site home page.  Although customErrors mode in web.config is set to "off" the error still does not display.  There does not seem to be an appropriate error log in /portals/_default so I am not sure how to track down the error that is being thrown.  I have tried both modifying the old web.config and modifying release.config with appropriate values, but get the same error no matter what..Anyone have any ideas on how to determine...

Error Upgrading 3.1.1 to 3.2.2
  I'm getting the following error when I browse to the side after uploading the upgrade files.  Any help would be appreciated! Notes:  Upgrade instructions followed exactly.            <trust level="Medium" originUrl="http://[mydomain].*" /> is set in web.config Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: Assembly fredck.fcked...

Another 3.2.3->3.4 error
Hello, I am running multiple bugzilla databases from a single installation. My first database upgraded ok but has some errors (see earlier post). However my second database is not working at all. check_setup ran fine but when you hit the web page you get: URL: https://someurl/index.cgi Template->process() failed twice. First error: file error - recursion into 'global/header.html.tmpl' Second error: file error - recursion into 'global/header.html.tmpl' Any ideas what could be going wrong here? Thanks, Will Will Wagner wrote: > First error: file e...

3.5.3 error
Name: Product: Firefox Summary: 3.5.3 error Comments: As of today,11/9/09 I can not access any sites at all on FireFox. My belief is that the 3.5.3 update was rushed or not efficiently checked before launched. Please,fix this as soon as possible. using Internet Explorer is a pain. Browser Details: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30618) From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this feedback ...

Error, Error and more errors
Okay, all I wanted to do was test this app out and it has been a nightmare. 1.) Didn't install the sql database. I had to manually install it. 2.) I get errors when trying to add a picture to an album. "Procedure or function ngUpdatePicture has too many arguments specified" Any ideas? I've gotten more errors than this, but there is no use in bitchin. Are you using the v1.6.1 installer? Also, did you select to install the SQL Server db and give it a valid admin login? What were some of the error messages? Did you have an existing DB from a previous install? ...

errors errors errors..
Name: harun Email: harunbjk1903hrnatgmaildotcom Product: Firefox Summary: errors errors errors.. Comments: first of all when i launch firefox (3) i cant enter websites via writing.. for example when I type "google" and then press ctrl and enter, it crashes.. and i take lots of error reports. firefox 2 was better.. see you again , harun Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.9) Gecko/2008052906 Firefox/3.0 From URL: http://hendrix.mozilla.org/ ...

error error error
These are the 2 new errors i am getting now:   1).  Server Error in '/' Application. Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.Source Error: Line 53: ...

error after upgrading Bugzilla from 3.2.2 to 3.2.3
Hi, I have two Windows Server 2003 machines running Bugzilla 3.2.2 + Testopia 2.2, one is production and the other is for test, both have same configuration. I tried to upgrade it with patch file bugzilla-3.2.2-to-3.2.3.diff.gz, and my steps are: 1) Shut down your Bugzilla installation by putting some HTML or text in the shutdownhtml parameter 2) untar the .diff file and use unix2dos.exe to replace Unix line feed characters with Windows carriage returns 3) run the command: path -p1 < bugzilla-3.2.2-to-3.2.3.diff 4) run the command: perl checksetup.pl 5) remove the text of shut...

Upgrading 3.0.3 to 3.2 database conversion error
I installed v3.2 on a new solaris server and brought over the data directory and restored the mysql 5.0.22 database. I ran the checksetup.pl after restoring and the conversion seemed to go along fine until this error when it tried to create a table. 2 things I notice here. It indicates MYISAM and I thought it was going to INNODB. We use INNODB for our databases. Also, when I originally installed, I had to change the bugzilla database character set =3D 'latin1' in order to have software transfers work. It may be nothing but I thought I would mention it. =20 Adding ...

NMAS Error after NMAS Patch for eDir OES Linux
--____NCKXBMMNONHUBRXUOGRT____ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: base64 Content-Disposition: inline; modification-date="Thu, 11 Jul 2007 12:27:42 +0200" SnVsIDExIDA5OjU3OjQ5ICBNZXRob2QgbG9hZCBmYWlsZWQ6IC92YXIvbmRzL25tYXMtbWV0aG9k cy9MU01NRDVMSU4uU086IHVuZGVmaW5lZCBzeW1ib2w6IGxkYXBfeF91dGY4c190b193Y3MNCkp1 bCAxMSAwOTo1Nzo0OSAgTWV0aG9kIGxvYWQgZmFpbGVkOiAvdXNyL2xpYi8vbmRzLW1vZHVsZXMv bGlibm1hcy5zbzogdmVyc2lvbiBgTk1BU19WRVJTSU9OXzIuMC4yJyBub3QgZm91bmQgKHJlcXVp cmVkIGJ5IC92YXINCi9uZHMvbm1hcy1tZXRob2RzL1g1MDlMU01MSU4uU08pDQoNCklzIHRoaXMg b25s...

Web resources about - SpiderMonkey: r/o Error = 3 vs. var Error = 3; - mozilla.dev.tech.js-engine

Resources last updated: 12/15/2015 12:53:17 AM