Check that a struct field name of a struct declaration does not shadow an enum or a struct definition.
This commit is contained in:
@@ -799,6 +799,16 @@ public class ContextAnalysis extends KlangBaseVisitor<Node> {
|
||||
throw new RuntimeException(Helper.getErrorPrefix(line, col) + error);
|
||||
}
|
||||
|
||||
if (structDefs.containsKey(structFieldName)) {
|
||||
var error = "Struct field name " + structFieldName + " shadows a struct of the same name.";
|
||||
throw new RuntimeException(Helper.getErrorPrefix(line, col) + error);
|
||||
}
|
||||
|
||||
if (enumDefs.containsKey(structFieldName)) {
|
||||
var error = "Struct field name " + structFieldName + " shadows an enum of the same name.";
|
||||
throw new RuntimeException(Helper.getErrorPrefix(line, col) + error);
|
||||
}
|
||||
|
||||
var structField = new StructField(structFieldName);
|
||||
structField.type = structFieldType;
|
||||
structField.line = line;
|
||||
|
||||
Reference in New Issue
Block a user