Fix Internal error when accessing polymorphic struct parameters (also provide suggestions?) #513

This commit is contained in:
gingerBill
2019-12-22 10:40:34 +00:00
parent 022b793a7d
commit 4f2d4716ad
+12 -1
View File
@@ -3254,7 +3254,18 @@ Entity *check_selector(CheckerContext *c, Operand *operand, Ast *node, Type *typ
return nullptr;
}
if (expr_entity != nullptr && is_type_polymorphic(expr_entity->type)) {
gbString op_str = expr_to_string(op_expr);
gbString type_str = type_to_string(operand->type);
gbString sel_str = expr_to_string(selector);
error(op_expr, "Cannot access field '%s' from non-specialized polymorphic type '%s'", sel_str, op_str);
gb_string_free(sel_str);
gb_string_free(type_str);
gb_string_free(op_str);
operand->mode = Addressing_Invalid;
operand->expr = node;
return nullptr;
}
add_entity_use(c, selector, entity);