summaryrefslogtreecommitdiff
path: root/py/compile.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-04-12 00:05:49 +0100
committerDamien George <damien.p.george@gmail.com>2014-04-12 00:05:49 +0100
commit7b4330191f98214c524e98106130e4b9f517cec1 (patch)
tree37d20f928a39e71c4cd5adfabd663a860f6247a7 /py/compile.c
parentc42e4b6c5364eae3c3db23627d2b3c661c0c2580 (diff)
py, compiler: Fix up creation of default positionals tuple.
With new order of evaluation of defaults, creating the tuple was done in the wrong spot.
Diffstat (limited to 'py/compile.c')
-rw-r--r--py/compile.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/py/compile.c b/py/compile.c
index b2a2c53f0..8d9d5fa52 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -915,6 +915,11 @@ void compile_funcdef_param(compiler_t *comp, mp_parse_node_t pn) {
#if !MICROPY_EMIT_CPYTHON
// in Micro Python we put the default dict parameters into a dictionary using the bytecode
if (comp->num_dict_params == 1) {
+ // in Micro Python we put the default positional parameters into a tuple using the bytecode
+ // we need to do this here before we start building the map for the default keywords
+ if (comp->num_default_params > 0) {
+ EMIT_ARG(build_tuple, comp->num_default_params);
+ }
// first default dict param, so make the map
EMIT_ARG(build_map, 0);
}
@@ -963,7 +968,8 @@ qstr compile_funcdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint
#if !MICROPY_EMIT_CPYTHON
// in Micro Python we put the default positional parameters into a tuple using the bytecode
- if (comp->num_default_params > 0) {
+ // the default keywords args may have already made the tuple; if not, do it now
+ if (comp->num_default_params > 0 && comp->num_dict_params == 0) {
EMIT_ARG(build_tuple, comp->num_default_params);
}
#endif