File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -93,13 +93,15 @@ mp_obj_t mp_load_const_bytes(qstr qstr) {
9393
9494mp_obj_t mp_load_name (qstr qstr ) {
9595 // logic: search locals, globals, builtins
96- DEBUG_OP_printf ("load name %s\n" , qstr_str (qstr ));
97- mp_map_elem_t * elem = mp_map_lookup (map_locals , MP_OBJ_NEW_QSTR (qstr ), MP_MAP_LOOKUP );
98- if (elem != NULL ) {
99- return elem -> value ;
100- } else {
101- return mp_load_global (qstr );
96+ DEBUG_OP_printf ("load name %s\n" , map_locals , qstr_str (qstr ));
97+ // If we're at the outer scope (locals == globals), dispatch to load_global right away
98+ if (map_locals != map_globals ) {
99+ mp_map_elem_t * elem = mp_map_lookup (map_locals , MP_OBJ_NEW_QSTR (qstr ), MP_MAP_LOOKUP );
100+ if (elem != NULL ) {
101+ return elem -> value ;
102+ }
102103 }
104+ return mp_load_global (qstr );
103105}
104106
105107mp_obj_t mp_load_global (qstr qstr ) {
You can’t perform that action at this time.
0 commit comments