]> Nishi Git Mirror - gwion.git/commitdiff
:art: Wrap 'fork' exp in a stmt_list
authorJérémie Astor <astor.jeremie@wanadoo.fr>
Sun, 24 May 2020 20:12:37 +0000 (22:12 +0200)
committerJérémie Astor <astor.jeremie@wanadoo.fr>
Sun, 24 May 2020 20:12:37 +0000 (22:12 +0200)
src/lib/func.c

index 5c697aeadeb76ce8e7184994dab8b16c515dcee9..a1084f3a832a1fe9ba95637b95a5ff5870c2150d 100644 (file)
@@ -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);