From 5b80a63433433563065aea984de2a3adf9557b03 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Wed, 17 Mar 2021 00:50:34 +0100 Subject: [PATCH] :art: Update --- ast | 2 +- plug | 2 +- src/emit/emit.c | 2 +- src/env/type.c | 1 + src/parse/check.c | 7 ++++--- src/parse/did_you_mean.c | 2 +- src/parse/scan1.c | 6 +++--- src/parse/traverse.c | 14 +++++++++----- src/parse/type_decl.c | 5 ++++- 9 files changed, 25 insertions(+), 16 deletions(-) diff --git a/ast b/ast index 88118d80..24a5f882 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit 88118d803a3256e2443b864a8bb3ab8c154289ba +Subproject commit 24a5f882a8c2e6ebddf8e05f19a8de0a94d884e1 diff --git a/plug b/plug index 86beb539..50e87bce 160000 --- a/plug +++ b/plug @@ -1 +1 @@ -Subproject commit 86beb5391447f86ff25890cb017fdb7753540e07 +Subproject commit 50e87bce8f22425e9ab55545226a9db5b67fde8e diff --git a/src/emit/emit.c b/src/emit/emit.c index b03152b5..87ebc592 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1804,7 +1804,7 @@ ANN static m_bool _emit_stmt_each(const Emitter emit, const Stmt_Each stmt, m_ui loop_idx->m_val2 = -1; stmt->v->from->offset = offset + SZ_INT *2; if(stmt->idx) - stmt->vidx->from->offset = offset + SZ_INT; + stmt->idx->v->from->offset = offset + SZ_INT; if(n) { const Instr instr = emit_add_instr(emit, AutoUnrollInit); instr->m_val = offset-SZ_INT; diff --git a/src/env/type.c b/src/env/type.c index 38b772ae..db2e5137 100644 --- a/src/env/type.c +++ b/src/env/type.c @@ -99,6 +99,7 @@ ANN /*static */Symbol array_sym(const Env env, const Type src, const m_uint dept #include "operator.h" #include "import.h" ANN Type array_type(const Env env, const Type src, const m_uint depth) { +if(src == env->gwion->type[et_auto])return src; const Symbol sym = array_sym(env, src, depth); const Type type = nspc_lookup_type1(src->info->owner, sym); if(type) diff --git a/src/parse/check.c b/src/parse/check.c index 3b972e7e..305e02cf 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -1012,9 +1012,10 @@ ANN static m_bool do_stmt_each(const Env env, const Stmt_Each stmt) { set_vflag(stmt->v, vflag_valid); nspc_add_value(env->curr, stmt->sym, stmt->v); if(stmt->idx) { - stmt->vidx = new_value(env->gwion->mp, env->gwion->type[et_int], s_name(stmt->idx)); - set_vflag(stmt->vidx, vflag_valid); - nspc_add_value(env->curr, stmt->idx, stmt->vidx); + stmt->idx->v = new_value(env->gwion->mp, env->gwion->type[et_int], s_name(stmt->idx->sym)); + valuefrom(env, stmt->idx->v->from, stmt->idx->pos); + set_vflag(stmt->idx->v, vflag_valid); + nspc_add_value(env->curr, stmt->idx->sym, stmt->idx->v); } return check_conts(env, stmt_self(stmt), stmt->body); } diff --git a/src/parse/did_you_mean.c b/src/parse/did_you_mean.c index cef3f5c8..b8b3d2e8 100644 --- a/src/parse/did_you_mean.c +++ b/src/parse/did_you_mean.c @@ -40,7 +40,7 @@ ANN static void ressembles(const Vector v, const Nspc nspc, const char* name) { continue; if(wagner_fisher(name, value->name)) { if(!vflag(value, vflag_builtin)) - gwerr_secondary("declared here", value->from->filename, value->from->loc); + gwerr_secondary("declared here", value->from->filename, value->from->loc); } } } diff --git a/src/parse/scan1.c b/src/parse/scan1.c index 60441a16..2feee138 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -286,8 +286,8 @@ ANN static inline m_bool scan1_stmt_match(const restrict Env env, const Stmt_Mat ANN static inline m_bool stmt_each_defined(const restrict Env env, const Stmt_Each stmt) { if(nspc_lookup_value1(env->curr, stmt->sym)) ERR_B(stmt_self(stmt)->pos, _("foreach value '%s' is already defined"), s_name(stmt->sym)) - if(stmt->idx && nspc_lookup_value1(env->curr, stmt->idx)) - ERR_B(stmt_self(stmt)->pos, _("foreach index '%s' is already defined"), s_name(stmt->idx)) + if(stmt->idx && nspc_lookup_value1(env->curr, stmt->idx->sym)) + ERR_B(stmt_self(stmt)->pos, _("foreach index '%s' is already defined"), s_name(stmt->idx->sym)) return GW_OK; } @@ -358,7 +358,7 @@ ANN static m_bool scan1_args(const Env env, Arg_List list) { if(list->td) { SET_FLAG(list->td, late); CHECK_OB((list->type = void_type(env, list->td))) - SET_FLAG(list->td, late); + UNSET_FLAG(list->td, late); } var->value = arg_value(env, list); nspc_add_value(env->curr, var->xid, var->value); diff --git a/src/parse/traverse.c b/src/parse/traverse.c index 6e37aab5..802a14c2 100644 --- a/src/parse/traverse.c +++ b/src/parse/traverse.c @@ -16,13 +16,17 @@ ANN m_bool traverse_exp(const Env env, const Exp exp) { return check_exp(env, exp) ? 1 : -1; } -ANN m_bool traverse_func_def(const Env env, const Func_Def def) { +ANN static m_bool _traverse_func_def(const Env env, const Func_Def fdef) { + CHECK_BB(scan1_func_def(env, fdef)) + CHECK_BB(scan2_func_def(env, fdef)) + return check_func_def(env, fdef); +} + +ANN m_bool traverse_func_def(const Env env, const Func_Def fdef) { const Func former = env->func; - const m_bool ret = scan1_func_def(env, def) > 0 && - scan2_func_def(env, def) > 0 && - check_func_def(env, def) > 0; + const m_bool ret = _traverse_func_def(env, fdef); env->func = former; - return ret ? GW_OK : GW_ERROR; + return ret; } ANN m_bool traverse_union_def(const Env env, const Union_Def def) { diff --git a/src/parse/type_decl.c b/src/parse/type_decl.c index 98b0a84d..b574f368 100644 --- a/src/parse/type_decl.c +++ b/src/parse/type_decl.c @@ -35,7 +35,10 @@ ANN static Type resolve(const Env env, Type_Decl* td) { DECL_OO(const Type, type, = scan_type(env, base, td)) const Type t = !td->ref ? type : ref(env, td); const Type ret = !td->option ? t : option(env, td); - return !td->array ? ret : array_type(env, ret, td->array->depth); +// if(!td->array || ret == env->gwion->type[et_auto]) +// return ret; +// return array_type(env, ret, td->array->depth); + return !td->array ? ret: array_type(env, ret, td->array->depth); } ANN static inline void* type_unknown(const Env env, const Type_Decl* td) { -- 2.43.0