mozilla / rhino

Rhino is an open-source implementation of JavaScript written entirely in Java
https://rhino.github.io
Other
4.18k stars 850 forks source link

IllegalArgumentException in Label.setName #663

Open jon-bell opened 4 years ago

jon-bell commented 4 years ago

We ran into an unexpected IllegalArgumentException when attempting to compile the following string using Rhino 1.7.12: \u000a:S<6

Stack trace:

Exception in thread "main" java.lang.IllegalArgumentException: invalid label name
    at org.mozilla.javascript.ast.Label.setName(Label.java:57)
    at org.mozilla.javascript.Parser.name(Parser.java:3236)
    at org.mozilla.javascript.Parser.primaryExpr(Parser.java:3125)
    at org.mozilla.javascript.Parser.memberExpr(Parser.java:2732)
    at org.mozilla.javascript.Parser.unaryExpr(Parser.java:2626)
    at org.mozilla.javascript.Parser.mulExpr(Parser.java:2547)
    at org.mozilla.javascript.Parser.addExpr(Parser.java:2531)
    at org.mozilla.javascript.Parser.shiftExpr(Parser.java:2512)
    at org.mozilla.javascript.Parser.relExpr(Parser.java:2487)
    at org.mozilla.javascript.Parser.eqExpr(Parser.java:2459)
    at org.mozilla.javascript.Parser.bitAndExpr(Parser.java:2448)
    at org.mozilla.javascript.Parser.bitXorExpr(Parser.java:2437)
    at org.mozilla.javascript.Parser.bitOrExpr(Parser.java:2426)
    at org.mozilla.javascript.Parser.andExpr(Parser.java:2415)
    at org.mozilla.javascript.Parser.orExpr(Parser.java:2404)
    at org.mozilla.javascript.Parser.condExpr(Parser.java:2368)
    at org.mozilla.javascript.Parser.assignExpr(Parser.java:2324)
    at org.mozilla.javascript.Parser.expr(Parser.java:2303)
    at org.mozilla.javascript.Parser.nameOrLabel(Parser.java:2052)
    at org.mozilla.javascript.Parser.statementHelper(Parser.java:1252)
    at org.mozilla.javascript.Parser.statement(Parser.java:1116)
    at org.mozilla.javascript.Parser.parse(Parser.java:653)
    at org.mozilla.javascript.Parser.parse(Parser.java:583)
    at org.mozilla.javascript.Context.parse(Context.java:2572)
    at org.mozilla.javascript.Context.compileImpl(Context.java:2521)
    at org.mozilla.javascript.Context.compileString(Context.java:1525)
    at org.mozilla.javascript.Context.compileString(Context.java:1514)
rbri commented 4 years ago

Can you please prepare a simple test case to make it easy for us to reproduce this.

You can have a look at the packages org.mozilla.javascript.tests.es5 or org.mozilla.javascript.tests.es6 for sample tests.