From c8b5d1177f04595b2df94d5164a980bf2702691d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Tue, 2 Jun 2020 00:51:25 +0200 Subject: [PATCH] :art: Improve type checking --- src/env/envset.c | 2 +- src/parse/check.c | 8 +++----- src/parse/scan1.c | 3 ++- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/env/envset.c b/src/env/envset.c index 5a7a239b..1b0aa7c5 100644 --- a/src/env/envset.c +++ b/src/env/envset.c @@ -22,7 +22,7 @@ ANN static m_bool push(struct EnvSet *es, const Type t) { CHECK_BB(push(es, t->e->owner_class)) else env_push(es->env, NULL, es->env->context->nspc); - if(!(t->flag & es->flag)) + if(es->func && !(t->flag & es->flag)) CHECK_BB(es->func((void*)es->data, t->e->def)) if(GET_FLAG(t, template)) CHECK_BB(template_push_types(es->env, t->e->def->base.tmpl)) diff --git a/src/parse/check.c b/src/parse/check.c index f118fa86..83910ce8 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -1013,11 +1013,9 @@ ANN static m_bool do_stmt_auto(const Env env, const Stmt_Auto stmt) { ptr = known_type(env, &td); td0->array = NULL; free_type_decl(env->gwion->mp, td0); - if(!GET_FLAG(ptr, check) && ptr->e->def) { - struct EnvSet es = { .env=env, .data=env, .func=(_exp_func)traverse_cdef, - .scope=env->scope->depth, .flag=ae_flag_check }; - CHECK_BB(envset_run(&es, get_type(ptr))) - } + const Type base = get_type(ptr); + if(!GET_FLAG(base, check)) + CHECK_BB(ensure_traverse(env, base)) } t = (!stmt->is_ptr && depth) ? array_type(env, ptr, depth) : ptr; stmt->v = new_value(env->gwion->mp, t, s_name(stmt->sym)); diff --git a/src/parse/scan1.c b/src/parse/scan1.c index d09cbd71..1c700c47 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -29,8 +29,9 @@ ANN static inline m_bool ensure_scan1(const Env env, const Type t) { } ANN static m_bool type_recursive(const Env env, const Type_Decl *td, const Type t) { + const Type base = get_type(t); if(!GET_FLAG(td, ref) && env->class_def && !env->scope->depth && - t == env->class_def) { + base == env->class_def) { ERR_B(td_pos(td), _("%s declared inside %s\n. (make it a ref ?)"), t->name, t == env->class_def ? "itself" : env->class_def->name); } -- 2.43.0