Community
Participate
Working Groups
The following XDCScript function causes parser to fail and outputs a java exception. function foo() { var a = 10; var b = 5; /* * ((a == 10) || b) is evaluated first and 5 is assigned to it. * This should result in an error pointing to this line and * file. */ if (a == 10 || b = 5) { } } But instead of an error, an exception occurred with a cryptic exception message which is not pointing to the file which caused this error. Snippet of the exception: js: ".", line 1: Invalid assignment left-hand side. js: js: ^ js: "C:/ti/xdctools_3_25_01_50_eng/packages/xdc/utils.js", line 647: null org.mozilla.javascript.WrappedException: Wrapped org.mozilla.javascript.Parser$ParserException (C:/ti/xdctools_3_25_01_5 0_eng/packages/xdc/utils.js#647) at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1754) at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:148) at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:225) at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1473) at script(C:/ti/xdctools_3_25_01_50_eng/packages/xdc/utils.js:647) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:815) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:109) at xdc.services.intern.xsr.Global.callFxn(Global.java:35) at iar_tools_configuro.Main$$TYPES(iar_tools_configuro.java:155) at iar_tools_configuro.exec(iar_tools_configuro.java:311) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ......
This appears to be a Rhino 1.7R4 regression: [sanblnx02 1008] cat foo.xs function foo() { var a = 10; var b = 5; if (a == 10 || b = 5) { } } [sanblnx02 1009] .../xdc/xdctools_3_24_07_73/Linux/xs -f foo.xs js: "./foo.xs", line 4: Invalid assignment left-hand side. js: if (a == 10 || b = 5) { js: ........................^ js: "./foo.xs", line 1: Compilation produced 1 syntax errors. "/db/rtree/library/trees/xdcprod/xdcprod-q73/product/Linux/xdctools_3_24_07_73/include/utils.tci", line 662 [sanblnx02 1010] .../xdc/xdctools_3_25_00_48/Linux/xs -f foo.xs js: ".", line 1: Invalid assignment left-hand side. js: js: ^ js: "/db/rtree/library/trees/xdcprod/xdcprod-r48/product/Linux/xdctools_3_25_00_48/packages/xdc/utils.js", line 503: null
The Rhino shell is not working correctly either: $TOOLS/vendors/oracle/jre/1.6.0_37/Linux/bin/java -cp $XDCTOOLS/xdctools_3_24_08_74_eng/Linux/packages/xdc/shelf/java/js.jar org.mozilla.javascript.tools.shell.Main test.js js: "test.js", line 3: Invalid assignment left-hand side. js: if (a == 5 || b = 10) { js: ....................^ js: "test.js", line 5: syntax error js: } js: ^ $TOOLS/vendors/oracle/jre/1.6.0_37/Linux/bin/java -cp $XDCTOOLS/xdctools_3_25_01_58_eng/Linux/packages/xdc/shelf/java/js.jar org.mozilla.javascript.tools.shell.Main test.js js: line 1: Invalid assignment left-hand side. js: js: ^ Exception in thread "main" org.mozilla.javascript.Parser$ParserException This does not look good for a quick fix.
I started a thread on mozilla-rhino newsgroup to see if anyone else had the same problem, and where the fix should be. http://groups.google.com/group/mozilla-rhino/browse_thread/thread/84e03acb14682459