Closed
Bug 492036
Opened 15 years ago
Closed 15 years ago
New AST code throws codebug on certain forms of destructuring assignment
Categories
(Rhino Graveyard :: Compiler, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: hannesw, Unassigned)
Details
Attachments
(2 files, 2 obsolete files)
58 bytes,
application/javascript
|
Details | |
1.04 KB,
patch
|
Details | Diff | Splinter Review |
From IRFactory.transformAssignment: (line 397) // TODO(stevey) // Bug: for code like "var obj={p:3};[obj.p]=[9];", "left" will // be ARRAYLITERAL with an embedded GETPROP. This causes errors // at codegen. Kit.codeBug(); Looking at dumps of the parse tree, I noticed that the difference between rhino 1.7R2 and cvs head is middle child node of the SETPROP is of type STRING in 1.7R2 and of type NAME in HEAD: WITH COMMA SETPROP - NAME obj 2 - NAME foo 2 + NAME obj + STRING foo NAME $1 NUMBER 0.0 LEAVEWITH So I came up with this really simple patch that sets the node type where it is created in Parser.simpleAssignment(). It seems to work, but it's a simple hack of course, so somebody who knows the parser/classgen should definitely look into this for a real solution.
Reporter | ||
Comment 1•15 years ago
|
||
set the node type of second SETPROP child to STRING to mirror pre-AST-refactoring output
Reporter | ||
Comment 2•15 years ago
|
||
Obviously, the string id should only be forced for SETPROP and not for SETELEM operations.
Attachment #376408 -
Attachment is obsolete: true
Reporter | ||
Comment 3•15 years ago
|
||
I noted that Norris recently removed the comment and Kit.codeBug(): http://bonsai.mozilla.org/cvsquery.cgi?treeid=default&module=all&branch=HEAD&branchtype=match&dir=&file=mozilla%2Fjs%2Frhino%2F&filetype=match&who=&whotype=match&sortby=Date&hours=2&date=explicit&mindate=2009-05-27+05%3A23&maxdate=2009-05-27+05%3A25&cvsroot=%2Fcvsroot Unfortunately the bug is still there, it just doesn't show in the Rhino shell because this is a codegen-only bug and the shell runs in interpreter mode, which is probably why Norris assumed the bug had been fixed. If nobody else comes up with a better solution, I suggest I'll commit my workaround patch with a big fat TODO comment including some explanation and a link to this bug.
Reporter | ||
Comment 4•15 years ago
|
||
Patch with the workaround that sets the GETPROP id type to STRING and a revised TODO comment with link to this bug.
Attachment #376478 -
Attachment is obsolete: true
Reporter | ||
Comment 5•15 years ago
|
||
Committed last patch. Checking in src/org/mozilla/javascript/Parser.java; /cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/Parser.java,v <-- Parser.java new revision: 1.141; previous revision: 1.140 done
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•