mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
Fix #713
This commit is contained in:
+8
-2
@@ -5572,9 +5572,15 @@ ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Ast *pr
|
|||||||
}
|
}
|
||||||
check_expr(c, operand, arg);
|
check_expr(c, operand, arg);
|
||||||
if (operand->mode != Addressing_Invalid) {
|
if (operand->mode != Addressing_Invalid) {
|
||||||
check_cast(c, operand, t);
|
if (is_type_polymorphic(t)) {
|
||||||
|
error(call, "A polymorphic type cannot be used in a type conversion");
|
||||||
|
} else {
|
||||||
|
// NOTE(bill): Otherwise the compiler can override the polymorphic type
|
||||||
|
// as it assumes it is determining the type
|
||||||
|
check_cast(c, operand, t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
operand->type = t;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-1
@@ -1271,7 +1271,13 @@ ParameterValue handle_parameter_value(CheckerContext *ctx, Type *in_type, Type *
|
|||||||
check_assignment(ctx, &o, in_type, str_lit("parameter value"));
|
check_assignment(ctx, &o, in_type, str_lit("parameter value"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (out_type_) *out_type_ = default_type(o.type);
|
if (out_type_) {
|
||||||
|
if (in_type != nullptr) {
|
||||||
|
*out_type_ = in_type;
|
||||||
|
} else {
|
||||||
|
*out_type_ = default_type(o.type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return param_value;
|
return param_value;
|
||||||
}
|
}
|
||||||
@@ -1389,6 +1395,9 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (type == nullptr) {
|
if (type == nullptr) {
|
||||||
error(param, "Invalid parameter type");
|
error(param, "Invalid parameter type");
|
||||||
type = t_invalid;
|
type = t_invalid;
|
||||||
@@ -1408,6 +1417,12 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is
|
|||||||
type = t_invalid;
|
type = t_invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (param_value.kind != ParameterValue_Invalid && is_type_polymorphic(type)) {
|
||||||
|
gbString str = type_to_string(type);
|
||||||
|
error(params[i], "A default value for a parameter must not be a polymorphic constant type, got %s", str);
|
||||||
|
gb_string_free(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (p->flags&FieldFlag_c_vararg) {
|
if (p->flags&FieldFlag_c_vararg) {
|
||||||
if (p->type == nullptr ||
|
if (p->type == nullptr ||
|
||||||
|
|||||||
Reference in New Issue
Block a user