Merge pull request #70713 from vonagam/fix-unnamed-enum-outer-conflicts
This commit is contained in:
commit
7319fa6082
3 changed files with 24 additions and 8 deletions
|
@ -1321,14 +1321,8 @@ GDScriptParser::EnumNode *GDScriptParser::parse_enum() {
|
|||
if (elements.has(item.identifier->name)) {
|
||||
push_error(vformat(R"(Name "%s" was already in this enum (at line %d).)", item.identifier->name, elements[item.identifier->name]), item.identifier);
|
||||
} else if (!named) {
|
||||
// TODO: Abstract this recursive member check.
|
||||
ClassNode *parent = current_class;
|
||||
while (parent != nullptr) {
|
||||
if (parent->members_indices.has(item.identifier->name)) {
|
||||
push_error(vformat(R"(Name "%s" is already used as a class %s.)", item.identifier->name, parent->get_member(item.identifier->name).get_type_name()));
|
||||
break;
|
||||
}
|
||||
parent = parent->outer;
|
||||
if (current_class->members_indices.has(item.identifier->name)) {
|
||||
push_error(vformat(R"(Name "%s" is already used as a class %s.)", item.identifier->name, current_class->get_member(item.identifier->name).get_type_name()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
class A:
|
||||
enum { X = 1 }
|
||||
|
||||
class B:
|
||||
enum { X = 2 }
|
||||
|
||||
class C:
|
||||
const X = 3
|
||||
|
||||
class D:
|
||||
enum { X = 4 }
|
||||
|
||||
func test():
|
||||
print(A.X)
|
||||
print(A.B.X)
|
||||
print(C.X)
|
||||
print(C.D.X)
|
|
@ -0,0 +1,5 @@
|
|||
GDTEST_OK
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
Loading…
Reference in a new issue