Skip to content

Commit 46a6592

Browse files
committed
py/emitglue: Refactor to remove assert(0), to improve coverage.
1 parent e4af712 commit 46a6592

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

py/emitglue.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,6 @@ mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_ar
126126
// make the function, depending on the raw code kind
127127
mp_obj_t fun;
128128
switch (rc->kind) {
129-
case MP_CODE_BYTECODE:
130-
no_other_choice:
131-
fun = mp_obj_new_fun_bc(def_args, def_kw_args, rc->data.u_byte.bytecode, rc->data.u_byte.const_table);
132-
break;
133129
#if MICROPY_EMIT_NATIVE
134130
case MP_CODE_NATIVE_PY:
135131
fun = mp_obj_new_fun_native(def_args, def_kw_args, rc->data.u_native.fun_data, rc->data.u_native.const_table);
@@ -144,9 +140,10 @@ mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_ar
144140
break;
145141
#endif
146142
default:
147-
// raw code was never set (this should not happen)
148-
assert(0);
149-
goto no_other_choice; // to help flow control analysis
143+
// rc->kind should always be set and BYTECODE is the only remaining case
144+
assert(rc->kind == MP_CODE_BYTECODE);
145+
fun = mp_obj_new_fun_bc(def_args, def_kw_args, rc->data.u_byte.bytecode, rc->data.u_byte.const_table);
146+
break;
150147
}
151148

152149
// check for generator functions and if so wrap in generator object

0 commit comments

Comments
 (0)