openwrt-packages/utils/jq/patches/0006-Replace-TOP-before-imp...

38 lines
1.1 KiB
Diff

From a114b871e460ef2ddcf7698bc6b18651c976626a Mon Sep 17 00:00:00 2001
From: Muh Muhten <muh.muhten@gmail.com>
Date: Tue, 19 Feb 2019 00:14:53 -0500
Subject: [PATCH 6/9] Replace TOP-before-imports special case with assert
The case isn't actually possible afaict.
---
src/compile.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
--- 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;
}