JSC: "missing ; after statement" message prints out for the line after the problem one

UNCONFIRMED
Unassigned

Status

Rhino
Compiler
UNCONFIRMED
6 years ago
6 years ago

People

(Reporter: Robert Flaherty, Unassigned)

Tracking

Details

(Reporter)

Description

6 years ago
User Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; BOIE9;ENUS)

Steps to reproduce:

Create a simple foo.js:

var a = 3
var b = 4;



Actual results:

Warning was:

warning: line 2: missing ; after statement
var b = 4;
...^


Expected results:

Warned the "var a = 3" was missing the semicolon.  I tried monkeying with Parser.java's autoInsertSemicolon() to look at the previous sibling node of pn without any luck.  Using 1.7R4.
I cannot reproduce the warning with 1.7R4. Are there any additional set-up steps required to trigger the warning?
(Reporter)

Comment 2

6 years ago
Yes, I set the strict mode on.  I have a related bug #391745, where I have a local copy of Main.java, and now add to processOptions(String args[]):

if (arg.equals("-strict")) {
    compilerEnv.setStrictMode(true);
    compilerEnv.setWarnTrailingComma(true);
    compilerEnv.setReservedKeywordAsIdentifier(false);
    continue;
}
(Reporter)

Comment 3

6 years ago
I'm guessing that the parser has moved on to the next token after where a semicolon would have been expected.  When it sees it in strict mode, it spits out what we see (...^ at var).  To be more useful, we would want to see the previous line (with ......^ at the very end).
(Reporter)

Comment 5

6 years ago
Thanks, works like a charm!
You need to log in before you can comment on or make changes to this bug.