Last Comment Bug 381203 - Anonymous setter functions!?
: Anonymous setter functions!?
Status: RESOLVED FIXED
: testcase
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: Trunk
: All All
: -- normal (vote)
: ---
Assigned To: general
:
: Jason Orendorff [:jorendorff]
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-05-18 15:59 PDT by Jesse Ruderman
Modified: 2011-11-27 12:22 PST (History)
5 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments

Description Jesse Ruderman 2007-05-18 15:59:56 PDT
js> s = setter function () { print("blah") }  
setter function () {
    print("blah");
}
Comment 1 Jesse Ruderman 2007-05-18 16:12:28 PDT
I think "setter function" should only be allowed as a declaration, not as an expression, to avoid bugs like:

js> f = (function() { (setter function f() { }).x }) 
function () {
    setter function f() {}.x;
}
js> eval("" + f)
typein:8: SyntaxError: syntax error:
typein:8:     setter function f() {}.x;
typein:8: ..........................^

And it should require there to be an identifier being set:

js> setter function () { print("blah") }  
setter function () {
    print("blah");
}

Comment 2 Jesse Ruderman 2007-05-18 16:24:20 PDT
But if they're only allowed as declarations, we'll have to do something about uneval spitting them out as expressions and/or disallow __lookupGetter__ from returning them:

js> getter function p() { print(4) }
js> uneval({x: this.__lookupGetter__("p")})
({x:getter function p() {print(4);}})
js> uneval([this.__lookupGetter__("p")])
[getter function p() {print(4);}]

Comment 3 Jesse Ruderman 2009-06-07 20:42:42 PDT
I think I heard rumblings of removing this feature(?) recently.
Comment 4 Ryan VanderMeulen [:RyanVM] 2011-11-27 12:14:47 PST
js> s = setter function () { print("blah") }
typein:11: SyntaxError: missing ; before statement:
typein:11: s = setter function () { print("blah") }
typein:11: ...........^
Comment 5 Jeff Walden [:Waldo] (remove +bmo to email) 2011-11-27 12:22:38 PST
Bug 517580 removed this syntax.

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