Fixed bug with default arguments in gdscript, closes #2024
This commit is contained in:
parent
e0eff65fc0
commit
cb39db0b02
2 changed files with 3 additions and 1 deletions
|
@ -1253,6 +1253,7 @@ Error GDCompiler::_parse_function(GDScript *p_script,const GDParser::ClassNode *
|
||||||
StringName func_name;
|
StringName func_name;
|
||||||
|
|
||||||
if (p_func) {
|
if (p_func) {
|
||||||
|
|
||||||
if (p_func->default_values.size()) {
|
if (p_func->default_values.size()) {
|
||||||
|
|
||||||
codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_TO_DEF_ARGUMENT);
|
codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_TO_DEF_ARGUMENT);
|
||||||
|
@ -1346,7 +1347,7 @@ Error GDCompiler::_parse_function(GDScript *p_script,const GDParser::ClassNode *
|
||||||
if (defarg_addr.size()) {
|
if (defarg_addr.size()) {
|
||||||
|
|
||||||
gdfunc->default_arguments=defarg_addr;
|
gdfunc->default_arguments=defarg_addr;
|
||||||
gdfunc->_default_arg_count=defarg_addr.size();
|
gdfunc->_default_arg_count=defarg_addr.size()-1;
|
||||||
gdfunc->_default_arg_ptr=&gdfunc->default_arguments[0];
|
gdfunc->_default_arg_ptr=&gdfunc->default_arguments[0];
|
||||||
} else {
|
} else {
|
||||||
gdfunc->_default_arg_count=0;
|
gdfunc->_default_arg_count=0;
|
||||||
|
|
|
@ -221,6 +221,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
|
||||||
r_err.error=Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
|
r_err.error=Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
|
||||||
r_err.argument=_argument_count;
|
r_err.argument=_argument_count;
|
||||||
|
|
||||||
|
|
||||||
return Variant();
|
return Variant();
|
||||||
} else if (p_argcount < _argument_count - _default_arg_count) {
|
} else if (p_argcount < _argument_count - _default_arg_count) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue