Bug 407608 - XDCscript parser errors no longer provide valid file line number info
Summary: XDCscript parser errors no longer provide valid file line number info
Status: ASSIGNED
Alias: None
Product: RTSC (ARCHIVED)
Classification: Technology
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Sasha Slijepcevic CLA
QA Contact:
URL:
Whiteboard:
Keywords: readme
Depends on:
Blocks:
 
Reported: 2013-05-08 21:18 EDT by Vikram Adiga CLA
Modified: 2013-06-25 17:35 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vikram Adiga CLA 2013-05-08 21:18:01 EDT
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)
  ......
Comment 1 Dave Russo CLA 2013-05-08 23:24:47 EDT
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
Comment 2 Sasha Slijepcevic CLA 2013-05-28 17:51:43 EDT
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.
Comment 3 Sasha Slijepcevic CLA 2013-06-03 17:30:18 EDT
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