diff options
| author | gingerBill <bill@gingerbill.org> | 2021-05-12 22:38:37 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-05-12 22:38:37 +0100 |
| commit | d962cfdc6bd1865c7df302d08af237027533437f (patch) | |
| tree | 12365aa358b2ebd422f2a0fd9499520174a1cec4 /src/check_type.cpp | |
| parent | dfb81431496f68bce56b9a92681a841b072300be (diff) | |
Fix #713
Diffstat (limited to 'src/check_type.cpp')
| -rw-r--r-- | src/check_type.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp index b90732e00..89f5ca34c 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -1271,7 +1271,13 @@ ParameterValue handle_parameter_value(CheckerContext *ctx, Type *in_type, Type * 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; } @@ -1389,6 +1395,9 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is } } } + + + if (type == nullptr) { error(param, "Invalid parameter type"); type = t_invalid; @@ -1408,6 +1417,12 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is 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->type == nullptr || |