You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This fixes a compiler/runtime bug where *args after a kwarg was not
handled correctly.
Prior to this change, if `*args` was encountered in a function call
after a keyword argument, the compiler would push a single object
and increment the positional arg count. However, two objects for the
keyword argument key and value had already been pushed. This caused
inconsistencies that the runtime could not resolve since it expects
all of the positional args first followed by key/value pairs for the
keyword args.
To fix it, we need to conditionally change what happens when `*args`
is encountered depending on if it is before or after the first keyword
argument. If it is before, everything is handled as before. If after,
instead of pushing a single object and incrementing the positional arg
count, we push two objects and increment the keyword arg count. This
makes it possible for the runtime to handle it with minimal changes.
In the runtime, we have to add some extra checks to handle the new
case of the possibility that one of the `n_kw` args is a `*arg`. We
already have a case where `**arg` is handled as a keyword argument
where the key is `MP_OBJ_NULL`. We now do the same for `*arg` as well.
The existing `star_args` flags is used to determine if the value
corresponding to a key of `MP_OBJ_NULL` is `*arg` or `**arg`.
A couple of test that failed before this fix are added.
Fixes: #11439
Signed-off-by: David Lechner <david@pybricks.com>
0 commit comments