From 154b2a20fb2948e4701f9bcbc462cff0819838d1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Sun, 24 May 2020 22:12:37 +0200 Subject: [PATCH] :art: Wrap 'fork' exp in a stmt_list --- src/lib/func.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lib/func.c b/src/lib/func.c index 5c697aea..a1084f3a 100644 --- a/src/lib/func.c +++ b/src/lib/func.c @@ -264,8 +264,17 @@ ANN Type check_exp_unary_spork(const Env env, const Stmt code); static OP_CHECK(opck_spork) { const Exp_Unary* unary = (Exp_Unary*)data; - if(unary->exp && unary->exp->exp_type == ae_exp_call) - return env->gwion->type[unary->op == insert_symbol("spork") ? et_shred : et_fork]; + if(unary->exp && unary->exp->exp_type == ae_exp_call) { + const m_bool is_spork = unary->op == insert_symbol("spork"); + if(!is_spork) { + const Stmt stmt = new_stmt_exp(env->gwion->mp, ae_stmt_exp, unary->exp); + const Stmt_List list = new_stmt_list(env->gwion->mp, stmt, NULL); + const Stmt code = new_stmt_code(env->gwion->mp, list); + ((Exp_Unary*)unary)->exp = NULL; + ((Exp_Unary*)unary)->code = code; + } + return is_spork ? et_shred : et_fork]; + } if(unary->code) { ++env->scope->depth; nspc_push_value(env->gwion->mp, env->curr); -- 2.43.0