Incorrect uneval with setter in object literal (involves anonymous function expression in eval)

VERIFIED FIXED

Status

()

Core
JavaScript Engine
VERIFIED FIXED
11 years ago
11 years ago

People

(Reporter: Jesse Ruderman, Assigned: Brian Crowder)

Tracking

(Blocks: 1 bug, {testcase})

Trunk
x86
Mac OS X
testcase
Points:
---
Dependency tree / graph
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

11 years ago
js> uneval({x setter: eval("function () { }") })
({set x ) {})

This has unmatched parens, so it doesn't compile.  If I put parens in the eval string (to comply with bug 376052), the bug goes away.

I also noticed this surprising difference:

js> uneval(eval("function() { }"))
function () {}
js> uneval(eval("(function() { })"))
(function () {})
(Reporter)

Updated

11 years ago
No longer blocks: 349611
(Reporter)

Updated

11 years ago
Blocks: 349611
(Assignee)

Comment 1

11 years ago
The patch in bug 367629 will fix this.
Assignee: general → crowder
Depends on: 367629
(Assignee)

Updated

11 years ago
Status: NEW → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → FIXED
(Reporter)

Updated

11 years ago
Flags: in-testsuite?
/cvsroot/mozilla/js/tests/js1_5/extensions/regress-380581.js,v  <--  regress-380581.js
initial revision: 1.1

drops the closing brace now.

BUGNUMBER: 380581
STATUS: Incorrect uneval with setter in object literal
expect:
 ( { set x ( ) { } } ) 
actual:
 ( { set x ( ) { } ) 
 FAILED! expected: [reported from test()] Expected value ' ( { set x ( ) { } } ) ', Actual value ' ( { set x ( ) { } ) ' 
 FAILED! expected: [reported from test()] Expected value 'No Error', Actual value 'SyntaxError: missing } after property list' 
expect:
 function ( ) { } 
actual:
 function ( ) { } 
PASSED! Incorrect uneval with setter in object literal
PASSED! Incorrect uneval with setter in object literal: compile actual
expect:
 ( function ( ) { } ) 
actual:
 ( function ( ) { } ) 
PASSED! Incorrect uneval with setter in object literal
PASSED! Incorrect uneval with setter in object literal: compile actual
Status: RESOLVED → REOPENED
Flags: in-testsuite? → in-testsuite+
Resolution: FIXED → ---
(Reporter)

Comment 3

11 years ago
Bug 381301 covers the missing closing brace.
Status: REOPENED → RESOLVED
Last Resolved: 11 years ago11 years ago
Resolution: --- → FIXED
(Assignee)

Comment 4

11 years ago
Jesse's correct, and the patch from bug 381301 will fix the regression mentioned in comment #2
Depends on: 381301
I'm now getting syntax errors on the expressions without the wrapping () but adding the parens fixes it. I'm checking in the change to the test, but if this is a real problem please ping me to revert it.

/cvsroot/mozilla/js/tests/js1_5/extensions/regress-380581.js,v  <--  regress-380581.js
new revision: 1.2; previous revision: 1.1
(Assignee)

Comment 6

11 years ago
Can you demonstrate the problem you're referring to here, bc?
I started getting 

STATUS: Incorrect uneval with setter in object literal
FAILED! expected: [reported from test()] syntax error 

on the trunk but this patch 

--- regress-380581.js   26 May 2007 13:43:40 -0000      1.1
+++ regress-380581.js   29 May 2007 22:41:06 -0000      1.2
@@ -55,11 +55,11 @@
   printStatus (summary);
  
   expect = '({ set x () {}})';
-  actual = uneval({x setter: eval("function () { }") });
+  actual = uneval({x setter: eval("(function () { })") });
   compareSource(expect, actual, summary);
   
-  expect = 'function() { }';
-  actual = uneval(eval("function() { }"));
+  expect = '(function() { })';
+  actual = uneval(eval("(function() { })"));
   compareSource(expect, actual, summary);

results in

BUGNUMBER: 380581
STATUS: Incorrect uneval with setter in object literal
expect: ( { set x ( ) { } } )
actual: ( { set x ( ) { } } )
PASSED! Incorrect uneval with setter in object literal
PASSED! Incorrect uneval with setter in object literal: compile actual
expect: ( function ( ) { } )
actual: ( function ( ) { } )
PASSED! Incorrect uneval with setter in object literal
PASSED! Incorrect uneval with setter in object literal: compile actual
expect: ( function ( ) { } )
actual: ( function ( ) { } )
PASSED! Incorrect uneval with setter in object literal
PASSED! Incorrect uneval with setter in object literal: compile actual 
(Assignee)

Comment 8

11 years ago
Ah, great, thanks.
(In reply to comment #8)
> Ah, great, thanks.

do we know why the behavior changed since 5/26? 

(Assignee)

Comment 10

11 years ago
This is the same function expression issue as before: https://bugzilla.mozilla.org/show_bug.cgi?id=376052 , but I do not know why the testcase behavior changed only recently.
verified fixed 1.9.0 linux/mac*/windows.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.