Merge pull request #73398 from anvilfolk/fix-getter

Fix unset getter return types resulting in strange behavior
This commit is contained in:
Rémi Verschelde 2023-02-17 00:31:42 +01:00
commit 68807165f4
No known key found for this signature in database
GPG key ID: C3336907360768E1
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