diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-10-12 16:01:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-12 16:01:57 +0200 |
commit | cb85ef6c38ec77041593ea89ba544d9cf74cf2a6 (patch) | |
tree | f5c5fed2d805d2d187f57fbd4e02c3d97862b44f /modules | |
parent | 480fc314500e969903a473d180ccf20b130cdbbb (diff) | |
parent | 45f546c1d8d692e76c4e00d2d38518b968787916 (diff) |
Merge pull request #53715 from vnen/gdscript-setter-parameter-type
Diffstat (limited to 'modules')
3 files changed, 13 insertions, 1 deletions
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index fd7664049a..9e9873d45f 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -893,11 +893,13 @@ void GDScriptAnalyzer::resolve_class_body(GDScriptParser::ClassNode *p_class) { resolve_function_body(member.variable->getter); } if (member.variable->setter != nullptr) { + resolve_function_signature(member.variable->setter); + if (member.variable->setter->parameters.size() > 0) { member.variable->setter->parameters[0]->datatype_specifier = member.variable->datatype_specifier; + member.variable->setter->parameters[0]->set_datatype(member.get_datatype()); } - resolve_function_signature(member.variable->setter); resolve_function_body(member.variable->setter); } } diff --git a/modules/gdscript/tests/scripts/analyzer/errors/setter_parameter_uses_property_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/setter_parameter_uses_property_type.gd new file mode 100644 index 0000000000..3bbee5f5f7 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/setter_parameter_uses_property_type.gd @@ -0,0 +1,8 @@ +var with_setter := 0: + set(val): + var x: String = val + with_setter = val + +func test(): + with_setter = 1 + print(with_setter) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/setter_parameter_uses_property_type.out b/modules/gdscript/tests/scripts/analyzer/errors/setter_parameter_uses_property_type.out new file mode 100644 index 0000000000..9eb2a42ccd --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/setter_parameter_uses_property_type.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +Value of type "int" cannot be assigned to a variable of type "String". |