struct Entity* entity_type;
struct Entity* entity_defaults;
+ OnyxFilePos polymorphic_error_loc;
ConstraintContext constraints;
b32 stcache_is_valid : 1;
if (s_node->constraints.constraints) {
s_node->constraints.produce_errors = (s_node->flags & Ast_Flag_Header_Check_No_Error) == 0;
- CHECK(constraint_context, &s_node->constraints, s_node->scope, s_node->token->pos);
+
+ OnyxFilePos pos = s_node->token->pos;
+ if (s_node->polymorphic_error_loc.filename) {
+ pos = s_node->polymorphic_error_loc;
+ }
+ CHECK(constraint_context, &s_node->constraints, s_node->scope, pos);
}
bh_arr_each(AstStructMember *, smem, s_node->members) {
onyx_report_error(constraint->exprs[constraint->expr_idx]->token->pos, Error_Critical, "Failed to satisfy constraint where %s.", constraint_map);
onyx_report_error(constraint->token->pos, Error_Critical, "Here is where the interface was used.");
+ onyx_report_error(pos, Error_Critical, "Here is the code that caused this constraint to be checked.");
return Check_Error;
default: return;
}
- *resolved = solve_poly_type(param->poly_sym, param->type_expr, actual_type);
+ PolySolveResult res = solve_poly_type(param->poly_sym, param->type_expr, actual_type);
+ if (res.kind == PSK_Undefined) {
+ *err_msg = bh_aprintf(global_scratch_allocator,
+ "Unable to solve for polymorphic variable '%b', given the type '%s'.",
+ param->poly_sym->token->text,
+ param->poly_sym->token->length,
+ type_get_name(actual_type));
+ }
+
+ *resolved = res;
}
insert_poly_slns_into_scope(sln_scope, slns);
AstStructType* concrete_struct = (AstStructType *) ast_clone(context.ast_alloc, ps_type->base_struct);
+ concrete_struct->polymorphic_error_loc = pos;
BH_MASK_SET(concrete_struct->flags, !error_if_failed, Ast_Flag_Header_Check_No_Error);
shput(ps_type->concrete_structs, unique_key, concrete_struct);