Commit 978607ae authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

objfun: Fix default arguments filling loop, was broken in presense of kwargs.

parent 41e2dea4
...@@ -299,9 +299,9 @@ continue2:; ...@@ -299,9 +299,9 @@ continue2:;
// Now fill in defaults // Now fill in defaults
mp_obj_t *d = &flat_args[self->n_args - 1]; mp_obj_t *d = &flat_args[self->n_args - 1];
mp_obj_t *s = &self->extra_args[self->n_def_args - 1]; mp_obj_t *s = &self->extra_args[self->n_def_args - 1];
for (int i = self->n_def_args; i > 0; i--) { for (int i = self->n_def_args; i > 0; i--, d--, s--) {
if (*d == MP_OBJ_NULL) { if (*d == MP_OBJ_NULL) {
*d-- = *s--; *d = *s;
} }
} }
DEBUG_printf("Args after filling defaults: "); DEBUG_printf("Args after filling defaults: ");
......
...@@ -11,3 +11,9 @@ foo(1, b=333) ...@@ -11,3 +11,9 @@ foo(1, b=333)
# override with keyword # override with keyword
foo(a=2, b=333) foo(a=2, b=333)
def foo2(a=1, b=2):
print(a, b)
# default and keyword
foo2(b='two')
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment