From a35cfc797bf931795b1e1963afa93930e5a4f607 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Mon, 19 Jun 2023 16:05:19 +0200 Subject: [PATCH] :art: simplify body ast --- ast | 2 +- src/parse/scan0.c | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ast b/ast index 2d0d0b37..58ede83c 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit 2d0d0b37334ea78006ec17c2af1425e117b544a0 +Subproject commit 58ede83c62af55bec048d0ce99081aa829540612 diff --git a/src/parse/scan0.c b/src/parse/scan0.c index 8d3b37bf..9f8e18b4 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -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; } -- 2.43.0