The default bug view has changed. See this FAQ.

Anonymous setter functions!?

RESOLVED FIXED

Status

()

Core
JavaScript Engine
RESOLVED FIXED
10 years ago
5 years ago

People

(Reporter: Jesse Ruderman, Unassigned)

Tracking

({testcase})

Trunk
testcase
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

10 years ago
js> s = setter function () { print("blah") }  
setter function () {
    print("blah");
}
(Reporter)

Comment 1

10 years ago
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");
}

(Reporter)

Comment 2

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

(Reporter)

Comment 3

8 years ago
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
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.