From 76473afdc3a0ea4cae6c8096a21e9e1c99b82506 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Sun, 31 May 2020 20:59:50 +0200 Subject: [PATCH] :bug: Fix static code emission --- src/emit/emit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/emit/emit.c b/src/emit/emit.c index a08ce3cc..0545d4b0 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1070,7 +1070,8 @@ ANN Instr emit_exp_call1(const Emitter emit, const Func f) { instr->m_val2 = val2; } else if(f->value_ref->from->owner_class && f != emit->env->func && !f->code&& ! is_fptr(emit->gwion, f->value_ref->type)){ /* not yet emitted static func */ - const Instr instr = (Instr)vector_back(&emit->code->instr); + const Instr instr = vector_size(&emit->code->instr) ? + (Instr)vector_back(&emit->code->instr) : emit_add_instr(emit, PushStaticCode); assert(instr->opcode == ePushStaticCode); instr->opcode = eRegPushImm; const Instr pushcode = emit_add_instr(emit, PushStaticCode); -- 2.43.0