janhaag/PSE2011 — Issue #18: ClassCastException after declring a variable like an array
Author: ratefuchs
Created: 2012-02-19 14:30:12+00:00
State: open

When parsing the program "main() { int i = array; }", the application crashes with the following stack trace:

Exception in thread "main" java.lang.ClassCastException: ast.IntegerType cannot be cast to ast.ArrayType
at interpreter.Scope.createArray(Scope.java:246)
at parser.TypeChecker.visit(TypeChecker.java:595)
at ast.ArrayDeclaration.accept(ArrayDeclaration.java:39)
at parser.TypeChecker.visit(TypeChecker.java:668)
at ast.StatementBlock.accept(StatementBlock.java:30)
at parser.TypeChecker.visit(TypeChecker.java:384)
at ast.Function.accept(Function.java:34)
at parser.TypeChecker.visit(TypeChecker.java:411)
at ast.Program.accept(Program.java:40)
at parser.TypeChecker.checkTypes(TypeChecker.java:40)
at parser.ParserInterface.parseProgram(ParserInterface.java:47)
at misc.ExecutionHandler.parse(ExecutionHandler.java:49)
at gui.controller.MainController.widgetSelected(MainController.java:265)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at gui.MainFrame.openWindow(MainFrame.java:256)
at gui.controller.MainController.initMainFrame(MainController.java:97)
at gui.controller.MainController.(MainController.java:85)
at misc.MainClass.main(MainClass.java:18)