aboutsummaryrefslogtreecommitdiff
path: root/src/ast.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2026-02-25 22:54:10 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2026-02-25 22:55:35 +0200
commit0dd32cca3b8ad7e2a34ec815996e68e2f81c1da1 (patch)
tree17227de8682888a254e5b57b955246c9c6c59b80 /src/ast.c
parentee50ee4ef760521c0764177b3bb8fed25beb2092 (diff)
downloadfwd-0dd32cca3b8ad7e2a34ec815996e68e2f81c1da1.tar.gz
fwd-0dd32cca3b8ad7e2a34ec815996e68e2f81c1da1.zip
filter out empty nodes from statement list
+ Fixes tail call analysis that was accidentally broken by 64146b46da45ce69ab380add00459f7b60fe9196 + Kind of wasteful to first allocate empty node and then just throw it away, but I don't have any better ideas at the moment
Diffstat (limited to 'src/ast.c')
-rw-r--r--src/ast.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/ast.c b/src/ast.c
index a39cb94..d7d97e0 100644
--- a/src/ast.c
+++ b/src/ast.c
@@ -567,6 +567,19 @@ struct type *reverse_type_list(struct type *root)
return new_root;
}
+struct ast *filter_empty(struct ast *root)
+{
+ struct ast *ret = root;
+ while (root) {
+ if (root->n && root->n->k == AST_EMPTY)
+ root->n = root->n->n;
+
+ root = root->n;
+ }
+
+ return ret;
+}
+
void fix_closures(struct ast *root)
{
while (root) {