Last Comment Bug 352045 - remove Object.prototype.eval
: remove Object.prototype.eval
Status: RESOLVED DUPLICATE of bug 382509
:
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: Trunk
: x86 Windows 2000
: -- minor (vote)
: ---
Assigned To: general
:
:
Mentors:
javascript:var foo=new Object();void(...
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-09-10 09:14 PDT by Hallvord R. M. Steen
Modified: 2014-01-27 09:43 PST (History)
6 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments

Description Hallvord R. M. Steen 2006-09-10 09:14:44 PDT
User-Agent:       Opera/9.01 (Windows NT 5.0; U; en)
Build Identifier:  Minefield 3.0a1/20060908

Having eval() in scope of every object is officially deprecated. It should be removed.

Documentation:
http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object:eval

Discussion regarding Opera bug report:
http://my.opera.com/hallvors/blog/show.dml/449976

Reproducible: Always
Comment 1 Brendan Eich [:brendan] 2006-09-10 10:46:59 PDT
We've talked about this in ECMA TG1.  My colleague from Opera reports that it is necessary to support indirect eval of the form w.eval for any window object w. But cross-browser JS does not require o.eval for any object o.  However, at least Venkman and probably many other XUL apps and extensions depend on this old SpiderMonkey feature (it goes back to the dawn of JS, 1995).

Object.prototype.eval is something we definitely want to remove, so this bug is good to have on file (is there an older one it dups, though? I have memories of another bug like this).  The Mozilla milestone in which to do this is Mozilla 2, when we can make big API compatibility breaks (not break all API compatibility promises, just big/old/deep ones like this particular one).  Mozilla 2 work should start soon; I'll have more to say about this within the next few weeks.

For ES4/JS2 we are considering support for eval(s, o) -- an optional second argument giving the scope chain (not an object to extend the scope chain, as SpiderMonkey does now via an internal translation to with(o)eval(s)) for the evaluation of s.

/be
Comment 2 Doug Wright 2006-09-10 12:49:02 PDT
(In reply to comment #1)
> Object.prototype.eval is something we definitely want to remove

The docs say it actually *was* removed in JS1.4. Was it removed and reinstated, or never removed?

Comment 3 Brendan Eich [:brendan] 2006-09-10 20:43:53 PDT
(In reply to comment #2)
> (In reply to comment #1)
> > Object.prototype.eval is something we definitely want to remove
> 
> The docs say it actually *was* removed in JS1.4. Was it removed and reinstated,
> or never removed?

The docs lie.  There's no trace in jsobj.c's CVS history (cvs annotate -rN jsobj.c | grep obj_eval and back N up to one before each change) that did not define eval as an Object.prototype method.  The incompatibility would have been as painful, or moreso, then than now.

/be
Comment 4 Doug Wright 2006-09-11 07:52:27 PDT
(In reply to comment #3)
> (In reply to comment #2)
> > (In reply to comment #1)
> > > Object.prototype.eval is something we definitely want to remove
> > 
> > The docs say it actually *was* removed in JS1.4. Was it removed and reinstated,
> > or never removed?
> 
> The docs lie.  There's no trace in jsobj.c's CVS history (cvs annotate -rN
> jsobj.c | grep obj_eval and back N up to one before each change) that did not
> define eval as an Object.prototype method.  The incompatibility would have been
> as painful, or moreso, then than now.
> 
> /be
> 

I've fixed the docs.
Comment 5 Daira Hopwood 2008-04-10 19:28:40 PDT
Isn't this a duplicate of bug 382509?
Comment 6 Blake Kaplan (:mrbkap) 2008-04-10 19:45:24 PDT
Yeah, duping forward.

*** This bug has been marked as a duplicate of bug 382509 ***

Note You need to log in before you can comment on or make changes to this bug.