summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/gdscript/gdscript_parser.cpp5
-rw-r--r--modules/gdscript/gdscript_parser.h1
2 files changed, 4 insertions, 2 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index 705f39ae78..adbd7e4e04 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -7458,7 +7458,8 @@ void GDScriptParser::_check_class_level_types(ClassNode *p_class) {
found_setter = true;
FunctionNode *setter = p_class->functions[j];
- if (setter->arguments.size() != 1) {
+ if (setter->get_required_argument_count() != 1 &&
+ !(setter->get_required_argument_count() == 0 && setter->default_values.size() > 0)) {
_set_error("Setter function needs to receive exactly 1 argument. See '" + setter->name +
"()' definition at line " + itos(setter->line) + ".",
v.line);
@@ -7477,7 +7478,7 @@ void GDScriptParser::_check_class_level_types(ClassNode *p_class) {
found_getter = true;
FunctionNode *getter = p_class->functions[j];
- if (getter->arguments.size() != 0) {
+ if (getter->get_required_argument_count() != 0) {
_set_error("Getter function can't receive arguments. See '" + getter->name +
"()' definition at line " + itos(getter->line) + ".",
v.line);
diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h
index 5ded4668a7..9c1ea1c7e4 100644
--- a/modules/gdscript/gdscript_parser.h
+++ b/modules/gdscript/gdscript_parser.h
@@ -221,6 +221,7 @@ public:
virtual DataType get_datatype() const { return return_type; }
virtual void set_datatype(const DataType &p_datatype) { return_type = p_datatype; }
+ int get_required_argument_count() { return arguments.size() - default_values.size(); }
FunctionNode() {
type = TYPE_FUNCTION;