Changes in Parser errors between 1.7R3 and 1.7R4

53 views
Skip to first unread message

Sasha Slijepcevic

unread,
Jun 3, 2013, 3:55:08 PM6/3/13
to mozill...@googlegroups.com
The following short script has a syntax error. The error was reported with the right line number in 1.7R3, but not in 1.7R4:
var a = 10;
var b = 5;
if (a == 5 || b = 10) print('ok');
 
C:\temp>"C:\Program Files (x86)\Java\jre7\bin\java.exe" -cp D:\Rhino1.7R3\js.jar org.mozilla.javascript.tools.shell.Main -f test.js
js: "test.js", line 3: Invalid assignment left-hand side.
js: if (a == 5 || b = 10) print('ok');
js: ....................^
 
C:\temp>"C:\Program Files (x86)\Java\jre7\bin\java.exe" -cp D:\Rhino1.7R4\js.jar org.mozilla.javascript.tools.shell.Main -f test.js
js: line 1: Invalid assignment left-hand side.
js:
js: ^
Exception in thread "main" org.mozilla.javascript.Parser$ParserException
        at org.mozilla.javascript.Parser.reportError(Parser.java:226)
        at org.mozilla.javascript.Parser.reportError(Parser.java:208)
        at org.mozilla.javascript.Parser.reportError(Parser.java:203)
        at org.mozilla.javascript.IRFactory.createAssignment(IRFactory.java:2139)
        at org.mozilla.javascript.IRFactory.transformAssignment(IRFactory.java:367)
        at org.mozilla.javascript.IRFactory.transform(IRFactory.java:152)
        at org.mozilla.javascript.IRFactory.transformIf(IRFactory.java:722)
        at org.mozilla.javascript.IRFactory.transform(IRFactory.java:110)
        at org.mozilla.javascript.IRFactory.transformScript(IRFactory.java:946)
        at org.mozilla.javascript.IRFactory.transform(IRFactory.java:132)
        at org.mozilla.javascript.IRFactory.transformTree(IRFactory.java:57)
        at org.mozilla.javascript.Context.compileImpl(Context.java:2366)
        at org.mozilla.javascript.Context.compileString(Context.java:1335)
        at org.mozilla.javascript.Context.compileString(Context.java:1324)
        at org.mozilla.javascript.tools.shell.Main.processFileSecure(Main.java:599)
        at org.mozilla.javascript.tools.shell.Main.processFile(Main.java:564)
        at org.mozilla.javascript.tools.shell.Main.processSource(Main.java:535)
        at org.mozilla.javascript.tools.shell.Main.processFiles(Main.java:178)
        at org.mozilla.javascript.tools.shell.Main$IProxy.run(Main.java:102)
        at org.mozilla.javascript.Context.call(Context.java:489)
        at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:504)
        at org.mozilla.javascript.tools.shell.Main.exec(Main.java:160)
        at org.mozilla.javascript.tools.shell.Main.main(Main.java:138)
 
I have traced the problem to IRFactory reporting errors without any info about the line number, and since IRFactory does not initialize a TokenStream instance, the error location info is not available in Parser.reportError. Any IRFactory call to reportError() with only the error message id supplied has to exhibit the same behaviour. Is this simply a bug, which I should file and possibly try to fix? Should Parser recognize that the left-hand side is not a variable?
Reply all
Reply to author
Forward
0 new messages