Make sure that a variable that references an enum has to be initialized.
This commit is contained in:
@@ -216,6 +216,11 @@ public class ContextAnalysis extends KlangBaseVisitor<Node> {
|
||||
variableDeclaration = new VariableDeclaration(variableName, (Expression) expression);
|
||||
variableDeclaration.initialized = true;
|
||||
} else {
|
||||
if (enumDefs.containsKey(declaredType.getName())) {
|
||||
var error = "Variable " + variableName + " references an enum but is not initialized.";
|
||||
throw new RuntimeException(Helper.getErrorPrefix(line, col) + error);
|
||||
}
|
||||
|
||||
variableDeclaration = new VariableDeclaration(variableName);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user