Closed Bug 239582 Opened 20 years ago Closed 20 years ago

Function.prototype.toString generates invalid javascript code

Categories

(Core :: JavaScript Engine, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: sjoerd, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040206 Firefox/0.8
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040206 Firefox/0.8

quoted identifiers are converted to regular identifiers, resulting in invalid code


Reproducible: Always
Steps to Reproduce:
function () { var x = {"a b": 1}; x["this"] = 2; }.toString()
Actual Results:  
function () { var x = {a b:1}; x.this = 2; } 

Expected Results:  
function () { var x = {"a b": 1}; x["this"] = 2; }

There are acutally 2 bugs: 
- quotes around keys in object literals are always removed.
i.e. {"a b":1} becomes {a b:1}
- quotes around keys in lookups are only removed when the result is valid
syntax, except it doesn't test for keywords
i.e. x["a b"] stays x["a b"], but x["this"] becomes x.this, which is invalid
This has been fixed since 1.6.  Please find the original bug and mark this
duplicate.
Whiteboard: DUPEME
Please test something more recent. This was fixed over two months ago.

/be
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → WORKSFORME
Oh, I see -- fx0.8 didn't pick up the 0.6 fix.  Branching early is one thing,
perhaps worth doing for fx-specific reasons, but not tracking 1.6 back-end
changes is a problem.

This is a tardy dup of bug 231518.

/be
Whiteboard: DUPEME
You need to log in before you can comment on or make changes to this bug.