Closed Bug 380946 Opened 14 years ago Closed 11 years ago

Unnecessary use of sharp by uneval with E4X

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
minor

Tracking

()

RESOLVED FIXED

People

(Reporter: jruderman, Unassigned)

References

Details

(Keywords: testcase)

Attachments

(1 file)

js> o = {}; o.a = <x><y/></x>; uneval(o);       
({a:#1=<x>
  <y/>
</x>})

The sharp variable doesn't seem necessary here.  It isn't used.

(Split from bug 380833.)
Blocks: e4x
Not only is it not used; it prevents the string returned by uneval from working.  "SyntaxError: invalid sharp variable definition" -- sharps have to be object literals or array literals, I think.
Attachment #440726 - Flags: review? → review?(jwalden+bmo)
(In reply to comment #2)
> patch that should solve the bug, plus regression test

With the patch what is the output of

js> x=<x/>;a={a:x, b:x};uneval(a);

is it 
  ({a:#1=<x/>, b:#1#})

Also please see Bug 335051
(In reply to comment #3)
> With the patch what is the output of
> js> x=<x/>;a={a:x, b:x};uneval(a);
> 

it is: ({a:<x/>, b:<x/>})

please disregard the patch, 
it needs more work, I'll look into it.
Attachment #440726 - Flags: review?(jwalden+bmo)
A bit of elaboration:

This error seems to occur with non-empty xml statements within objects, ie. problem with: 
uneval({a:<x>foo</x>}) -> "({a:#1=<x>foo</x>})"
but not with:
uneval({a:<x/>}) -> "({a:<x/>})"

Uneval of objects and arrays behaves different, 
such that objects use sharps with xml whereas arrays do not, ie:
x=<x/>; uneval({a:x,b:x}) -> "({a:#1=<x/>, b:#1#})"
x=<x/>; uneval([x, x]) -> "[<x/>, <x/>]"
(also demonstrated in Biju's example 11 in bug 335051), 

The earlier patch changes uneval of objects such that it does not use sharps on xml - a behavior similar to arrays uneval - and I doubt this is the wanted behaviour, and it adds a bit of code. This bug will probably less of an issue when bug 335051 is done.

This bug may be a sub-bug or duplicate of bug 379519 (together with 335051).

Also, thanks a lot to Waldo, Biju, Brendan, and Gary, for fast feedback on bug 463360, bug 335051, and this bug.
Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.3a5pre) 
Gecko/20100520 Minefield/3.7a5pre 

Case 1 -------------------------------
o = {}; o.a = <x><y/></x>; uneval(o);   
==>
({a:#1=<x>
  <y/>
</x>})

Case 2 -------------------------------
x=<x/>;a={a:x, b:x};uneval(a);
===>
({a:#1=<x/>, b:#1#})

Case 3 -------------------------------
x=<x/>;a={a:x};uneval(a);
===>
({a:<x/>})
Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.3a5pre) 
Gecko/20100526 Minefield/3.7a5pre

Case 1 -------------------------------
o = {}; o.a = <x><y/></x>; uneval(o);  
===>
({a:<x>
  <y/>
</x>})

Case 2 -------------------------------
x=<x/>;a={a:x, b:x};uneval(a);
===>
({a:#1=<x/>, b:#1#})

Case 3 -------------------------------
x=<x/>;a={a:x};uneval(a);
===>
({a:<x/>})


Assuming this is PASSED by bug 335051 attachment 444050 [details] [diff] [review]
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.