Closed Bug 306738 Opened 19 years ago Closed 19 years ago

uneval() on an object with getter or setter has unmatched parenthesis

Categories

(Core :: JavaScript Engine, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: ldavismead, Assigned: mrbkap)

References

()

Details

(Keywords: js1.5, testcase, verified1.8)

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20050901 SeaMonkey/1.1a

Doing something like
uneval(
{
   get foo()
   {
      return "foo";
   }
});

gives ({get foo(){return "foo";})}) as its output, which has a mismatched
parenthesis.  Unevaling a function results in (function(){}), so I suspect that
the getter/setter uneval code is delegating to the function uneval code,
stripping the leading "(" and then failing to strip the trailing ")".  Eval only
understands ({get foo(){return "foo";}}):  I can't stick an extra set of parens
around the getter in any way.

Reproducible: Always

Steps to Reproduce:
Click on the testcase URL.
Actual Results:  
({get foo(){return "foo";})}) is alerted.

Expected Results:  
({get foo(){return "foo";}}) should be alerted.

Also occurs in:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0

Also occurs when using a setter, or when getters or setters have been added
using the (not-so) super-secret __define{S,G}etter__ object methods.
Component: General → JavaScript Engine
Product: Mozilla Application Suite → Core
Version: unspecified → Trunk
Whoops.  I got confused by the shiny new bug wizard and filed this under general
browser instead of core javascript (I missed "other" on the main page).  Sorry
for the spam.
Keywords: testcase
QA Contact: general → general
Assignee: general → general
Status: UNCONFIRMED → NEW
Ever confirmed: true
QA Contact: general → general
I have a newfound liking of the decompiler. I'll take this.
Assignee: general → mrbkap
Status: NEW → ASSIGNED
The problem was that js_obj_toSource wasn't accounting for the parentheses at
all. This patch makes it do that (and removes the spurious space between the
getter name and the opening parameter parenthesis.
Attachment #194608 - Flags: review?(brendan)
Comment on attachment 194608 [details] [diff] [review]
Account for parentheses

Beef that comment up to avoid the window/orphan as discussed!

/be
Attachment #194608 - Flags: review?(brendan)
Attachment #194608 - Flags: review+
Attachment #194608 - Flags: approval1.8b4+
Flags: blocking1.8b4+
Keywords: js1.5
Fix checked into MOZILLA_1_8_BRANCH and trunk.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Keywords: fixed1.8
Resolution: --- → FIXED
Checking in regress-306738.js;
/cvsroot/mozilla/js/tests/js1_5/Regress/regress-306738.js,v  <--  regress-306738.js
initial revision: 1.1
done
Flags: testcase+
verified fixed 1.8.x and trunk.
Status: RESOLVED → VERIFIED
Keywords: fixed1.8verified1.8
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: