Closed Bug 40760 Opened 24 years ago Closed 24 years ago

JS1.5 getters and setters may replace native properties

Categories

(Core :: JavaScript Engine, defect, P3)

defect

Tracking

()

RESOLVED FIXED

People

(Reporter: brendan, Assigned: brendan)

References

()

Details

(Keywords: js1.5)

Attachments

(3 files)

Waldemar's write-up said that it should be "verboten", e.g., to replace the lastIndex property of a regular expression with a getter or setter. We do protect permanent properties, but not readonly and not "native" -- there is no internal attribute for such properties. Suggestions on how to implement this are welcome. /be
Status: NEW → ASSIGNED
Keywords: js1.5
Target Milestone: --- → M16
JSPROP_FINAL seems like the right thing. Mega-patch coming up. /be
Setting URL to the deja.com remembrance of waldemar's posting. Thinking about this more, does it behoove us to protect properties that lack a DontDelete attribute from being overridden by a getter and/or setter? Suppose we make re.lastIndex final -- one could still delete re.lastIndex and redefine it with a getter and setter that do non-standard magic. /be
re.lastIndex is DontDelete according to ECMA v3.
Ok (lastIndex not being DontDelete is an ECMA ed. 3 bug that slipped past the testsuite, I guess; I'll fix it). But are there any properties that lack DontDelete, but that should be protected from getter/setter replacement? Or are there properties that are not DontDelete in ECMA yet, but that (given extensions __defineGetter__ and __defineSetter__) should now be DontDelete? /be
This patch fixes and externs js_CheckRedeclartion so it can be used from obj_defineGetter and obj_defineSetter (the native methods for __defineGetter__ and __defineSetter__). It also makes RegExp.prototype.lastIndex PERMANENT, but what about all those other properties (ignoreCase, source, etc.)? I don't have ECMA ed. 3 handy right now. Phil, can you update the testsuite and report bogusly-deletable properties that ECMA says should be DontDelete? /be
I found an E262-3.pdf, and notice that the following are DontDelete, but are not JSPROP_PERMANENT in SpiderMonkey: 12.14: catch variables 15.1.1.1: NaN in the global object 15.1.1.2: Infinity in the global object 15.1.1.3: undefined in the global object 15.3.5.2: f.prototype for a function f 15.5.5.1: s.length for a string s 15.10.7: all properties of regular expression objects That's it. I'll have an updated patch shortly. Phil, anyone, double-check me if you please. JS1.5 is supposed to comply with ECMA-262 Edition 3. /be
Here comes the new patch. It's bigger than I'd like, because I had to add a new bytecode for catch-variable setup. Cc'ing shaver. /be
While you're in jsopcode.c, can you fix the decompilation bug? len = js_GetSrcNoteOffset(sn, 0); pc += 4; /* initprop, enterwith */ if (len) { - js_printf(jp, " : "); + js_printf(jp, " if "); Other than that, it looks good.
Fix checked in. /be
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: