diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index fad2bf334b4..09c8954e640 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -242,7 +242,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code // Try class members. if (_is_class_member_property(codegen, identifier)) { // Get property. - GDScriptCodeGenerator::Address temp = codegen.add_temporary(); // TODO: Could get the type of the class member here. + GDScriptCodeGenerator::Address temp = codegen.add_temporary(_gdtype_from_datatype(p_expression->get_datatype(), codegen.script)); gen->write_get_member(temp, identifier); return temp; } diff --git a/modules/gdscript/tests/scripts/runtime/features/conversions_from_native_members.gd b/modules/gdscript/tests/scripts/runtime/features/conversions_from_native_members.gd new file mode 100644 index 00000000000..a778fb1a946 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/conversions_from_native_members.gd @@ -0,0 +1,11 @@ +class Foo extends Node: + func _init(): + name = 'f' + var string: String = name + assert(typeof(string) == TYPE_STRING) + assert(string == 'f') + print('ok') + +func test(): + var foo := Foo.new() + foo.free() diff --git a/modules/gdscript/tests/scripts/runtime/features/conversions_from_native_members.out b/modules/gdscript/tests/scripts/runtime/features/conversions_from_native_members.out new file mode 100644 index 00000000000..1b47ed10dc0 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/conversions_from_native_members.out @@ -0,0 +1,2 @@ +GDTEST_OK +ok