Add return type for GDScript getters

This commit is contained in:
ocean (they/them) 2023-02-15 16:00:22 -05:00
parent f2aae8fa5c
commit 94dfac8da7
3 changed files with 12 additions and 1 deletions

View file

@ -254,7 +254,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
if (codegen.script->member_indices.has(identifier)) {
if (codegen.script->member_indices[identifier].getter != StringName() && codegen.script->member_indices[identifier].getter != codegen.function_name) {
// Perform getter.
GDScriptCodeGenerator::Address temp = codegen.add_temporary();
GDScriptCodeGenerator::Address temp = codegen.add_temporary(codegen.script->member_indices[identifier].data_type);
Vector<GDScriptCodeGenerator::Address> args; // No argument needed.
gen->write_call_self(temp, codegen.script->member_indices[identifier].getter, args);
return temp;

View file

@ -0,0 +1,9 @@
var Value:int = 8 :
get:
return Value
set(v):
Value = v
func test():
var f:float = Value
print(int(f))

View file

@ -0,0 +1,2 @@
GDTEST_OK
8