From: Jérémie Astor Date: Tue, 12 May 2020 20:12:50 +0000 (+0200) Subject: :bug: Fix slice X-Git-Tag: nightly~1569 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=0c855204970b6b8f31446b9c8b1b88091b14c916;p=gwion.git :bug: Fix slice --- diff --git a/src/emit/emit.c b/src/emit/emit.c index 7846646f..7d9cf851 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -429,7 +429,7 @@ ANN static m_bool emit_exp_slice(const Emitter emit, const Exp_Slice* range) { const Symbol sym = insert_symbol("@slice"); const Exp e = range->range->start ?: range->range->end; struct Op_Import opi = { .op=sym, .lhs=e->info->type, .rhs=range->base->info->type, - .pos=e->pos, .data=(uintptr_t)range->base, .op_type=op_exp }; + .pos=e->pos, .data=(uintptr_t)exp_self(range), .op_type=op_exp }; CHECK_OB(op_emit(emit, &opi)) return GW_OK; } diff --git a/src/lib/array.c b/src/lib/array.c index 1808730b..d203d71e 100644 --- a/src/lib/array.c +++ b/src/lib/array.c @@ -196,7 +196,8 @@ static OP_CHECK(opck_array_cast) { static OP_CHECK(opck_array_slice) { const Exp e = (Exp)data; - return e->info->type; + exp_setmeta(exp_self(e), 1); + return e->d.exp_slice.base->info->type; } static inline m_bool bounds(const M_Vector v, const m_int i) { @@ -339,6 +340,9 @@ GWION_IMPORT(array) { GWI_BB(gwi_oper_ini(gwi, "@Array", "@Array", NULL)) GWI_BB(gwi_oper_add(gwi, opck_array_at)) GWI_BB(gwi_oper_end(gwi, "@=>", ObjectAssign)) + GWI_BB(gwi_oper_ini(gwi, "@null", "@Array", NULL)) + GWI_BB(gwi_oper_add(gwi, opck_array_at)) + GWI_BB(gwi_oper_end(gwi, "@=>", ObjectAssign)) GWI_BB(gwi_oper_ini(gwi, "nonnull @Array", (m_str)OP_ANY_TYPE, NULL)) GWI_BB(gwi_oper_add(gwi, opck_array_shift)) GWI_BB(gwi_oper_emi(gwi, opem_array_shift)) diff --git a/src/parse/check.c b/src/parse/check.c index 9270a82d..65666927 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -369,7 +369,7 @@ static ANN Type check_exp_slice(const Env env, const Exp_Slice* range) { const Symbol sym = insert_symbol("@slice"); const Exp e = range->range->start ?: range->range->end; struct Op_Import opi = { .op=sym, .lhs=e->info->type, .rhs=range->base->info->type, - .pos=e->pos, .data=(uintptr_t)range->base, .op_type=op_exp }; + .pos=e->pos, .data=(uintptr_t)exp_self(range), .op_type=op_exp }; return op_check(env, &opi); }