Closed
Bug 381205
Opened 19 years ago
Closed 19 years ago
object uneval gets confused by special "getter functions"
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
VERIFIED
FIXED
People
(Reporter: jruderman, Assigned: crowderbt)
Details
(Keywords: testcase)
Attachments
(1 file, 1 obsolete file)
|
2.19 KB,
patch
|
mrbkap
:
review+
|
Details | Diff | Splinter Review |
js> getter function p() { print(4) }
js> uneval({x getter: this.__lookupGetter__("p")})
({get x ction p() {print(4);})
I think it's trying to remove "function", but the first 8 characters are "getter f". And it's also confused by it being a getter for "x" and being a getter for "p" at the same time.
Creating the object this way should probably be a runtime type error, just like:
js> j = 3; ({x getter: j})
typein:3: SyntaxError: invalid getter usage
(It says "SyntaxError", but it's really a runtime type error, see bug 352316.)
| Reporter | ||
Comment 1•19 years ago
|
||
Much happier now that bug 367629 is fixed:
js> getter function p() { print(4) }
js> uneval({x getter: this.__lookupGetter__("p")})
({get x () {print(4);}})
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Comment 2•19 years ago
|
||
Checking in regress-381205.js;
/cvsroot/mozilla/js/tests/js1_5/extensions/regress-381205.js,v <-- regress-381205.js
initial revision: 1.1
with SyntaxError instead of TypeError
Jesse, do you really not get an error as in comment 1?
Flags: in-testsuite+
| Reporter | ||
Comment 3•19 years ago
|
||
When I run the commands in comment 1, I don't get any errors. (Is that what you were asking?)
Comment 4•19 years ago
|
||
(In reply to comment #3)
> When I run the commands in comment 1, I don't get any errors. (Is that what
> you were asking?)
>
Yes, but I am still confused.
js> getter function p() { print(4) }
js> uneval({x getter: this.__lookupGetter__("p")})
({get x () {print(4);})
js> function f() { getter function p() { print(4) }; uneval({x getter: this.__lookupGetter__("p")}) }
js> f()
typein:1: SyntaxError: invalid getter usage
| Reporter | ||
Comment 5•19 years ago
|
||
In the latter, this.__lookupGetter__("p") returns |undefined| because "p" is only bound within f's scope. You'd see the same thing with a normal function or a local variable.
js> function f() { getter function p() { }; print(this.__lookupGetter__("p")); }
js> f()
undefined
Comment 6•19 years ago
|
||
/cvsroot/mozilla/js/tests/js1_5/extensions/regress-381205.js,v <-- regress-381205.js
new revision: 1.2; previous revision: 1.1
Comment 7•19 years ago
|
||
New results are:
Expected value '({get x () {print(4);})',
Actual value '({get x function p() {print(4);}})'
Comment 8•19 years ago
|
||
Oops, I bet looking for the first space finds the space after 'getter'.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
| Assignee | ||
Comment 9•19 years ago
|
||
I hate how this routine seems to grow with each tweak.
Comment 10•19 years ago
|
||
Comment on attachment 266646 [details] [diff] [review]
using getter/setter flags on the function to decide whether to skip "getter"/"setter"
>Index: jsobj.c
>+ if (JSFUN_GETTER_TEST(fun->flags) ||
>+ JSFUN_SETTER_TEST(fun->flags)) /* skip "getter/setter" */
>+ vchars = js_strchr_limit(vchars, ' ', end) + 1;
Add braces around the if body and r=mrbkap.
At least we're converging on something sane!
Attachment #266646 -
Flags: review?(mrbkap) → review+
| Assignee | ||
Comment 11•19 years ago
|
||
Sorry for the review-harassment mrbkap, trying to reassure my paranoid self that this is as memory-safe as it can be.
Attachment #266646 -
Attachment is obsolete: true
Attachment #266654 -
Flags: review?(mrbkap)
Comment 12•19 years ago
|
||
Comment on attachment 266654 [details] [diff] [review]
Added a null-check and a check for a space character where I expect one
>Index: jsobj.c
>+ JS_ASSERT(fun);
In general, we these sorts of assertions are rare, since we'll catch this sort of problem by null-deref crashing down below, so I'd say "take it out!".
Attachment #266654 -
Flags: review?(mrbkap) → review+
| Assignee | ||
Comment 13•19 years ago
|
||
jsobj.c: 3.345
Status: ASSIGNED → RESOLVED
Closed: 19 years ago → 19 years ago
Resolution: --- → FIXED
Comment 14•19 years ago
|
||
I assume that actual: ({get x p() {print(4);}}) is ok for the decompilation now?
Comment 15•19 years ago
|
||
/cvsroot/mozilla/js/tests/js1_5/extensions/regress-381205.js,v <-- regress-381205.js
new revision: 1.3; previous revision: 1.2
changed expected decompilation and fixed a missing brace in the expected value.
Comment 16•18 years ago
|
||
verified fixed 1.9.0 linux/mac*/windows but the test fails due to bug 393269
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•