From: Jérémie Astor Date: Sat, 7 Aug 2021 01:09:51 +0000 (+0200) Subject: :bug: Fix array concat emission (type check) X-Git-Tag: nightly~480 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=a13dac44beeb47e972fb4276d4badced98fb6850;p=gwion.git :bug: Fix array concat emission (type check) --- diff --git a/src/lib/array.c b/src/lib/array.c index 90a06d79..cba963e0 100644 --- a/src/lib/array.c +++ b/src/lib/array.c @@ -128,6 +128,11 @@ static OP_CHECK(opck_array_at) { return bin->rhs->type; } +ANN static inline bool shift_match(const Type base, const Type more) { + return isa(more, base) > 0 && + get_depth(base) == get_depth(more); +} + ANN static Type check_array_shift(const Env env, const Exp a, const Exp b, const m_str str, const loc_t pos) { /* if(a->type == env->gwion->type[et_error] && @@ -136,7 +141,7 @@ ANN static Type check_array_shift(const Env env, const Exp a, const Exp b, ARRAY_OPCK(a, b, pos) if (a->type->array_depth == b->type->array_depth + 1) return a->type; - else if (a->type->array_depth == b->type->array_depth) + else if (shift_match(a->type, b->type)) return a->type; ERR_N(pos, "array depths do not match for '%s'.", str); } @@ -200,11 +205,6 @@ static INSTR(ArrayConcatRight) { memmove(ARRAY_PTR(base), ARRAY_PTR(more), ARRAY_LEN(more) * sz); } -ANN static inline bool shift_match(const Type base, const Type more) { - return isa(more, base) > 0 && - get_depth(base) == get_depth(more); -} - static OP_EMIT(opem_array_sr) { const Exp_Binary *bin = (Exp_Binary *)data; if (shift_match(bin->lhs->type, bin->rhs->type))