From 2e7b402586f88d57544dd900e192dfa0197da388 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Tue, 5 May 2020 14:54:24 +0200 Subject: [PATCH] :bug: Fix for builtin structs --- src/emit/emit.c | 5 +++-- src/lib/object_op.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/emit/emit.c b/src/emit/emit.c index 93b27452..ba7c7739 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -485,7 +485,7 @@ ANN static m_bool emit_prim_str(const Emitter emit, const m_str *str) { #define emit_prim_nil (void*)dummy_func ANN static inline void struct_interp(const Emitter emit, const Exp e) { - if(GET_FLAG(e->info->type, struct)) { + if(GET_FLAG(e->info->type, struct) && !GET_FLAG(e->info->type, builtin)) { exp_setvar(e, 1); regpush(emit, e->info->type->size - SZ_INT); } @@ -757,7 +757,8 @@ ANN static m_bool emit_exp_call(const Emitter emit, const Exp_Call* exp_call) { const Instr instr = emit_add_instr(emit, Reg2RegAddr); instr->m_val = -SZ_INT; instr->m_val2 = -SZ_INT; - } + } else if(!exp_call->m_func && GET_FLAG(e->info->type, struct)) + regpop(emit, SZ_INT); return GW_OK; } diff --git a/src/lib/object_op.c b/src/lib/object_op.c index 90ab1d1e..be5cd561 100644 --- a/src/lib/object_op.c +++ b/src/lib/object_op.c @@ -139,7 +139,7 @@ ANN static Type scan_class(const Env env, const Type t, const Type_Decl* td); OP_CHECK(opck_object_scan) { struct TemplateScan *ts = (struct TemplateScan*)data; - if(ts->td->types) + if(ts->td->types && GET_FLAG(ts->t, template) && ts->t->e->def) return scan_class(env, ts->t, ts->td); if(!GET_FLAG(ts->t, template) || GET_FLAG(ts->t, unary)) return ts->t; -- 2.43.0