Skip to content

Commit 942ecab

Browse files
author
dlsmith
committed
DynamicJava: Fix for bug when array initializer is assigned to a non-array type.
git-svn-id: file:///tmp/test-svn/trunk@5216 fe72c1cf-3628-48e9-8b72-1c46755d3cff
1 parent 24fd185 commit 942ecab

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

dynamicjava/src/edu/rice/cs/dynamicjava/interpreter/ExpressionChecker.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,11 @@ private DJClass resolveThis(Option<String> outerName, Node node) {
837837
// (and that can be turned on or off depending on preferences),
838838
// the stated element type is always required and checked
839839
// TODO: Store the *Type* as an attribute on the initializer, instead of a *TypeName*?
840-
Type elementType = checkTypeName(node.getElementType());
840+
TypeName elementTypeName = node.getElementType();
841+
if (elementTypeName == null) {
842+
throw new ExecutionError("array.initializer.type", node);
843+
}
844+
Type elementType = checkTypeName(elementTypeName);
841845
if (expected.isSome() && ts.isArray(expected.unwrap())) {
842846
checkList(node.getCells(), ts.arrayElementType(expected.unwrap()));
843847
}

dynamicjava/src/koala/dynamicjava/interpreter/resources/messages.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ array.dimension.type = Bad array dimension expression type
170170
# Used by TypeChecker
171171
array.index.type = Bad array index expression type
172172

173+
array.initializer.type = Array initializer must be assigned to an array type
174+
173175
# Used by ClassInfoCompiler, TypeChecker
174176
array.required = '%0' is not an array
175177

0 commit comments

Comments
 (0)