const Type base = parent->e->d.base_type;
if(base && !GET_FLAG(base, emit))
CHECK_BB(emit_cdef(emit, base->e->def))
- return !GET_FLAG(parent, emit) ? emit_cdef(emit, parent->e->def) : GW_OK;
+ return !GET_FLAG(parent, emit) ? scanx_parent(parent, emit_cdef, emit) : GW_OK;
}
ANN static inline m_bool emit_cdef(const Emitter emit, const Class_Def cdef) {
const Type r = bin->rhs->type;
if(opck_rassign(env, data, mut) == t_null)
return t_null;
+ if(check_nonnull(env, l, r, "assign", exp_self(bin)->pos) == t_null)
+ return t_null;
if(bin->rhs->exp_type == ae_exp_decl)
SET_FLAG(bin->rhs->d.exp_decl.td, ref);
- CHECK_OO(check_nonnull(env, l, r, "assign", exp_self(bin)->pos))
bin->rhs->emit_var = 1;
return r;
}
#include "type.h"
ANN static void free_value(Value a, Gwion gwion) {
- const Type t = !GET_FLAG(a->type, nonnull) ? a->type : a->type->e->parent;
+ const Type t = a->type;
if(!GET_FLAG(a, func) && a->d.ptr && !GET_FLAG(a, union) &&
!(GET_FLAG(a, enum) && GET_FLAG(a, builtin) && a->owner_class)
&& isa(t, t_object) < 0)
if(!v->owner_class || isa(t, v->owner_class) < 0) {
ERR_B(pos,
_("'%s' from owner namespace '%s' used in '%s'."),
- v->name, v->owner->name, t->name)
+ v->name, v->owner ? v->owner->name : "?", t->name)
}
return GW_OK;
}
array->exp->d.exp_primary.primary_type != ae_primary_num)
ERR_O(array->exp->pos, _("tuple subscripts must be litteral"))
const m_uint idx = array->exp->d.exp_primary.d.num;
+ if(idx >= vector_size(&array->type->e->tuple->types))
+ ERR_O(array->exp->pos, _("tuple subscripts too big"))
const Type type = (Type)vector_at(&array->type->e->tuple->types, idx);
if(type == t_undefined)
ERR_O(array->exp->pos, _("tuple subscripts is undefined"))
ANN static Type partial_depth(const Env env, const Array_Sub array) {
const Exp curr = take_exp(array->exp, array->type->array_depth);
- if(!curr->next)
+ if(!curr->next || !array_base(array->type))
ERR_O(array->exp->pos, _("array subscripts (%i) exceeds defined dimension (%i)"),
array->depth, get_depth(array->type))
struct Array_Sub_ next = { curr->next, array_base(array->type), array->depth - array->type->array_depth };
if(isa(parent, t_object) < 0)
ERR_B(pos, _("cannot extend primitive type '%s'"), parent->name)
if(parent->e->def && !GET_FLAG(parent, scan1))
-// CHECK_BB(scanx_parent(parent, scan1_cdef, env))
- CHECK_BB(scan1_cdef(env, parent->e->def))
+ CHECK_BB(scanx_parent(parent, scan1_cdef, env))
if(type_ref(parent))
ERR_B(pos, _("can't use ref type in class extend"))
return GW_OK;
do {
const Type t = tl->td->xid->xid != insert_symbol("_") ?
known_type(env, tl->td) : (Type)1;
- if(!t)
- break;
- vector_add(&v, (m_uint)t);
+ if(t)
+ vector_add(&v, (m_uint)t);
+ else {
+ vector_release(&v);
+ return NULL;
+ }
} while((tl = tl->next));
const Type ret = tuple_type(env, &v, td_pos(td));
vector_release(&v);
if(t->nspc)
ADD_REF(t->nspc)
t->name = s_name(sym);
- t->e->parent = ret;
+ t->flag = ret->flag;
SET_FLAG(t, nonnull);
map_set(&t->e->owner->info->type->map, (vtype)sym, (vtype)t);
return t;