]> Nishi Git Mirror - gwion.git/commitdiff
:art: simplify body ast
authorfennecdjay <fennecdjay@gmail.com>
Mon, 19 Jun 2023 14:05:19 +0000 (16:05 +0200)
committerfennecdjay <fennecdjay@gmail.com>
Mon, 19 Jun 2023 14:05:19 +0000 (16:05 +0200)
ast
src/parse/scan0.c

diff --git a/ast b/ast
index 2d0d0b37334ea78006ec17c2af1425e117b544a0..58ede83c62af55bec048d0ce99081aa829540612 160000 (submodule)
--- a/ast
+++ b/ast
@@ -1 +1 @@
-Subproject commit 2d0d0b37334ea78006ec17c2af1425e117b544a0
+Subproject commit 58ede83c62af55bec048d0ce99081aa829540612
index 8d3b37bfdb235592ddf17d760f3dc7041edb6f93..9f8e18b4bbc97efd6309706e08db7473fe54cb89 100644 (file)
@@ -477,7 +477,15 @@ ANN static m_bool _scan0_trait_def(const Env env, const Trait_Def pdef) {
         ERR_B(fdef->base->pos, "Trait function must be declared without qualifiers");
       if (!trait->fun) trait->fun = new_mp_vector(env->gwion->mp, Func_Def, 0);
       mp_vector_add(env->gwion->mp, &trait->fun, Func_Def, fdef);
-    }
+    } else if (section->section_type == ae_section_stmt) {
+      Stmt_List list = section->d.stmt_list;
+      for(uint32_t i = 0; i < list->len; i++) {
+        Stmt stmt = mp_vector_at(list, struct Stmt_, i);
+        if(stmt->d.stmt_exp.val->exp_type != ae_exp_decl)
+        ERR_B(stmt->pos, "trait can only contains variable requests and functions");
+      }
+    } else
+        ERR_B(pdef->pos, "invalid section for trait definition");
   }
   return GW_OK;
 }