ANN static void check_extend(const Env env, Ast ast) {
for(m_uint i = 0; i < ast->len; i++) {
Section * section = mp_vector_at(ast, Section, i);
- (void)check_section(env, section);
+ if(section->poison) continue;
+ if(!check_section(env, section)) {
+ section->poison = true;
+ continue;
+ }
mp_vector_add(env->gwion->mp, &env->context->tree, Section, *section);
}
free_mp_vector(env->gwion->mp, Section, env->context->extend);
ANN bool check_ast(const Env env, Ast *ast) {
Ast a = *ast;
+ bool ok = true;
for(m_uint i = 0; i < a->len; i++) {
Section * section = mp_vector_at(a, Section, i);
- if(section->poison) return false;
+ if(section->poison) {
+ ok = false;
+ continue;
+ }
if(!check_section(env, section)) {
section->poison = true;
- return false;
+ ok = false;
}
}
- if(vector_size(&env->scope->effects)) check_unhandled(env);
if(env->context->extend) check_extend(env, env->context->extend);
- return true;
+ if(ok && vector_size(&env->scope->effects)) check_unhandled(env);
+ return ok;
}
static m_bool typecheck_ast(const Env env, Ast *ast) {
env->scope->poison = false; // move me
- CHECK_b(traverse_ast(env, ast));
+ scan0_ast(env, ast);
if(env->scope->poison)env->context->error = true;
+ scan1_ast(env, ast);
+ if(env->scope->poison)env->context->error = true;
+ scan2_ast(env, ast);
+ if(env->scope->poison)env->context->error = true;
+ CHECK_b(check_ast(env, ast));
+ if(env->scope->poison)env->context->error = true;
+// CHECK_b(traverse_ast(env, ast));
+// if(env->scope->poison)env->context->error = true;
if(env->context->error)return GW_ERROR;
return GW_OK;
}