Closed Bug 788070 Opened 13 years ago Closed 13 years ago

AstNode addition within switch-case failing

Categories

(Rhino Graveyard :: Core, defect)

1.7R1
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: tntim96, Unassigned)

Details

Attachments

(1 file)

Attached file BugDemo.java
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0 Build ID: 20120824154833 Steps to reproduce: Run attached program Actual results: Exception in thread "main" java.lang.NullPointerException at org.mozilla.javascript.Node.getChildBefore(Node.java:222) at org.mozilla.javascript.Node.addChildBefore(Node.java:287) at BugDemo.visit(BugDemo.java:45) at org.mozilla.javascript.ast.ExpressionStatement.visit(ExpressionStatement.java:119) at org.mozilla.javascript.ast.SwitchCase.visit(SwitchCase.java:149) at org.mozilla.javascript.ast.SwitchStatement.visit(SwitchStatement.java:175) at org.mozilla.javascript.ast.ScriptNode.visit(ScriptNode.java:312) at org.mozilla.javascript.ast.AstRoot.visitAll(AstRoot.java:110) at BugDemo.addIncrement(BugDemo.java:28) at BugDemo.main(BugDemo.java:16) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) Expected results: source = switch (x) { case x: x++; y = 0; break; default: x = 0; break; }
Usage of the AST is incorrect. Rather than use AstNode.addChildBefore(newChild, node); the statement list in the SwitchCase code needs to be manipulated.
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: