Closed Bug 381203 Opened 17 years ago Closed 13 years ago

Anonymous setter functions!?

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jruderman, Unassigned)

Details

(Keywords: testcase)

js> s = setter function () { print("blah") }  
setter function () {
    print("blah");
}
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");
}

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);}]

I think I heard rumblings of removing this feature(?) recently.
js> s = setter function () { print("blah") }
typein:11: SyntaxError: missing ; before statement:
typein:11: s = setter function () { print("blah") }
typein:11: ...........^
OS: Mac OS X → All
Hardware: x86 → All
Bug 517580 removed this syntax.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.