GDScript: Fix subscript resolution on constant non-metatype GDScript base

This commit is contained in:
Danil Alexeev
2024-05-30 15:52:42 +03:00
parent 25519867f2
commit 18d8838051
3 changed files with 56 additions and 7 deletions

View File

@@ -25,12 +25,24 @@ func test():
if str(property.name).begins_with("test_"):
print(Utils.get_property_signature(property))
print("---")
check_gdscript_native_class(test_native)
check_gdscript(test_script)
check_gdscript(test_class)
check_enum(test_enum)
print("---")
print(test_native.stringify([]))
print(test_script.TEST)
print(test_class.TEST)
print(test_enum.keys())
print("---")
# Some users add unnecessary type hints to `const`-`preload`, which removes metatypes.
# For **constant** `GDScript` we still check the class members, despite the wider type.
const ScriptNoMeta: GDScript = Other
const ClassNoMeta: GDScript = MyClass
var a := ScriptNoMeta.TEST
var b := ClassNoMeta.TEST
print(a)
print(b)

View File

@@ -3,11 +3,16 @@ var test_native: GDScriptNativeClass
var test_script: GDScript
var test_class: GDScript
var test_enum: Dictionary
---
GDScriptNativeClass
GDScript
GDScript
{ "A": 0, "B": 1, "C": 2 }
---
[]
100
10
["A", "B", "C"]
---
100
10