janhaag/PSE2011 — Issue #75: IllegalStateException when trying to use function call as array index
Author: linjin
Created: 2012-03-01 16:08:23+00:00
State: open

The following program

int foo() {
return 0;
}
main(int[] a) {
a[0] = a[foo()];
}

throws

Exception in thread "main" java.lang.IllegalStateException: Function may only be set once!
at ast.FunctionCall.setFunction(FunctionCall.java:48)
at parser.TypeChecker.visit(TypeChecker.java:268)
at ast.FunctionCall.accept(FunctionCall.java:37)
at parser.TypeChecker.visit(TypeChecker.java:191)
at ast.LogicalExpression.accept(LogicalExpression.java:69)
...