case EXPR_UNARY_DEREFERENCE: {
const expression_t *const value = expression->unary.value;
type_t *const type = skip_typeref(value->base.type);
- assert(is_type_pointer(type));
+ if (!is_type_pointer(type))
+ return type_error_type;
return type->pointer.points_to;
}
case EXPR_ARRAY_ACCESS: {
const expression_t *array_ref = expression->array_access.array_ref;
type_t *type_left = skip_typeref(array_ref->base.type);
- if (!is_type_valid(type_left))
- return type_left;
- assert(is_type_pointer(type_left));
+ if (!is_type_pointer(type_left))
+ return type_error_type;
return type_left->pointer.points_to;
}