diff --git a/src/compile.c b/src/compile.c index 9cbf683f..3d3132f7 100644 --- a/src/compile.c +++ b/src/compile.c @@ -469,10 +469,10 @@ block block_drop_unreferenced(block body) { jv block_take_imports(block* body) { jv imports = jv_array(); - inst* top = NULL; - if (body->first && body->first->op == TOP) { - top = block_take(body); - } + /* Parser should never generate TOP before imports */ + assert(!(body->first && body->first->op == TOP && body->first->next && + (body->first->next->op == MODULEMETA || body->first->next->op == DEPS))); + while (body->first && (body->first->op == MODULEMETA || body->first->op == DEPS)) { inst* dep = block_take(body); if (dep->op == DEPS) { @@ -480,9 +480,6 @@ jv block_take_imports(block* body) { } inst_free(dep); } - if (top) { - *body = block_join(inst_block(top),*body); - } return imports; }