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)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
M16
People
(Reporter: brendan, Assigned: brendan)
References
()
Details
(Keywords: js1.5)
Attachments
(3 files)
6.49 KB,
patch
|
Details | Diff | Splinter Review | |
14.68 KB,
patch
|
Details | Diff | Splinter Review | |
14.34 KB,
patch
|
Details | Diff | Splinter Review |
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
Assignee | ||
Updated•24 years ago
|
Assignee | ||
Comment 1•24 years ago
|
||
JSPROP_FINAL seems like the right thing. Mega-patch coming up.
/be
Assignee | ||
Comment 2•24 years ago
|
||
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
Comment 3•24 years ago
|
||
re.lastIndex is DontDelete according to ECMA v3.
Assignee | ||
Comment 4•24 years ago
|
||
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
Assignee | ||
Comment 5•24 years ago
|
||
Assignee | ||
Comment 6•24 years ago
|
||
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
Assignee | ||
Comment 7•24 years ago
|
||
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
Assignee | ||
Comment 8•24 years ago
|
||
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
Assignee | ||
Comment 9•24 years ago
|
||
Comment 10•24 years ago
|
||
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.
Assignee | ||
Comment 11•24 years ago
|
||
Assignee | ||
Comment 12•24 years ago
|
||
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.
Description
•