Closed Bug 114491 Opened 23 years ago Closed 23 years ago

blowout on conditional anonymous function invocation

Categories

(Rhino Graveyard :: Compiler, defect)

x86
Windows NT
defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: rokicki, Assigned: norrisboyd)

Details

E:\p4test\main\dev>java -version
java version "1.2.2"
Java HotSpot(TM) Server VM (2.0rc1, mixed mode, build I)

E:\p4test\main\dev>java -jar e:/rhino/js.jar
js> if (true) function f(){}()
Exception in thread "main" java.lang.NullPointerException
        at org.mozilla.javascript.IRFactory.setFunctionExpressionStatement(IRFac
tory.java:235)
        at org.mozilla.javascript.Parser.statementHelper(Parser.java:767)
        at org.mozilla.javascript.Parser.statement(Parser.java:334)
        at org.mozilla.javascript.Parser.statementHelper(Parser.java:376)
        at org.mozilla.javascript.Parser.statement(Parser.java:334)
        at org.mozilla.javascript.Parser.parse(Parser.java:133)
        at org.mozilla.javascript.Context.stringIsCompilableUnit(Context.java:81
0)
        at org.mozilla.javascript.tools.shell.Main.processSource(Main.java:213)
        at org.mozilla.javascript.tools.shell.Main.exec(Main.java:104)
        at org.mozilla.javascript.tools.shell.Main.main(Main.java:66)

Happens on linux with jdk1.3.0 too.
I'm seeing the same thing. Note the following variations:

-----------------------  NO CONDITIONAL -------------------------------------
js> function f(){}()
js: "<stdin>", line 1: uncaught JavaScript exception: SyntaxError: syntax error                                                                
(<stdin>; line 1)
js: function f(){}()
js: ...............^


-----------------------  NO INVOCATION -------------------------------------
js> if (true) function f(){}

function f() {
}


------------------  CONDITIONAL + INVOCATION--------------------------------
js> if (true) function f(){}()
Exception in thread "main" java.lang.NullPointerException
        at org.mozilla.javascript.IRFactory.setFunctionExpressionStatement(IRFac
tory.java:234)
        at org.mozilla.javascript.Parser.statementHelper(Parser.java:813)
        at org.mozilla.javascript.Parser.statement(Parser.java:382)
        at org.mozilla.javascript.Parser.statementHelper(Parser.java:424)
        at org.mozilla.javascript.Parser.statement(Parser.java:382)
        at org.mozilla.javascript.Parser.parse(Parser.java:125)
        at 
org.mozilla.javascript.Context.stringIsCompilableUnit(Context.java:814)
        at org.mozilla.javascript.tools.shell.Main.processSource(Main.java:215)
        at org.mozilla.javascript.tools.shell.Main.exec(Main.java:106)
        at org.mozilla.javascript.tools.shell.Main.main(Main.java:68)
Testcase added to JS testsuite:

          mozilla/js/tests/js1_5/Regress/regress-114491.js
Fixed:

Checking in IRFactory.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/IRFactory.java,v  <--  IRFa
ctory.java
new revision: 1.20; previous revision: 1.19
done
Checking in Parser.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/Parser.java,v  <--  Parser.
java
new revision: 1.21; previous revision: 1.20
done
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Verified FIXED. The construct produces a syntax error instead of crashing.
The testcase above now passes in both the rhino and rhinoi shells.
Status: RESOLVED → VERIFIED
Targeting as resolved against 1.5R3
Target Milestone: --- → 1.5R3
You need to log in before you can comment on or make changes to this bug.