summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-03-27 11:27:08 +1100
committerDamien George <damien.p.george@gmail.com>2017-03-27 11:27:08 +1100
commit40c1272e5516b8d847118c06c7d222410075fa09 (patch)
treed622af41e37b0230c1736676ab23374a93d21b51
parenta0973b09ce203be95729ed8215f9333a29caa35d (diff)
downloadmicropython-40c1272e5516b8d847118c06c7d222410075fa09.tar.gz
micropython-40c1272e5516b8d847118c06c7d222410075fa09.zip
py/compile: When compiling super(), handle closed-over self variable.
The self variable may be closed-over in the function, and in that case the call to super() should load the contents of the closure cell using LOAD_DEREF (before this patch it would just load the cell directly).
-rw-r--r--py/compile.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/py/compile.c b/py/compile.c
index 2fbc19cc39..1e49a350f9 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -2190,9 +2190,10 @@ STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_ar
compile_load_id(comp, MP_QSTR___class__);
// look for first argument to function (assumes it's "self")
for (int i = 0; i < comp->scope_cur->id_info_len; i++) {
- if (comp->scope_cur->id_info[i].flags & ID_FLAG_IS_PARAM) {
+ id_info_t *id = &comp->scope_cur->id_info[i];
+ if (id->flags & ID_FLAG_IS_PARAM) {
// first argument found; load it and call super
- EMIT_LOAD_FAST(MP_QSTR_, comp->scope_cur->id_info[i].local_num);
+ compile_load_id(comp, id->qst);
EMIT_ARG(call_function, 2, 0, 0);
return;
}