diff options
| author | gingerBill <bill@gingerbill.org> | 2020-02-26 22:53:40 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2020-02-26 22:53:40 +0000 |
| commit | 3d74c2f6c0797345c2bdfae77c619057227e8181 (patch) | |
| tree | 4dd52d97f21a46b1ad6c57c9625344202bb7281d /src/check_expr.cpp | |
| parent | 1596bca92d4d8b3457cbfacec24e2a2129bba40e (diff) | |
Add `proc(#const x: Type)` to enforce a constant parameter (but not polymorphic) to a procedure
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index b8fe76f6d..1a01eef31 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -5991,6 +5991,15 @@ CALL_ARGUMENT_CHECKER(check_call_arguments_internal) { } score += s; + if (e->flags & EntityFlag_ConstInput) { + if (o.mode != Addressing_Constant) { + if (show_error) { + error(o.expr, "Expected a constant value for the argument '%.*s'", LIT(e->token.string)); + } + err = CallArgumentError_NoneConstantParameter; + } + } + if (o.mode == Addressing_Type && is_type_typeid(e->type)) { add_type_info_type(c, o.type); add_type_and_value(c->info, o.expr, Addressing_Value, e->type, exact_value_typeid(o.type)); @@ -6246,6 +6255,15 @@ CALL_ARGUMENT_CHECKER(check_named_call_arguments) { } err = CallArgumentError_WrongTypes; } + + if (e->flags & EntityFlag_ConstInput) { + if (o->mode != Addressing_Constant) { + if (show_error) { + error(o->expr, "Expected a constant value for the argument '%.*s'", LIT(e->token.string)); + } + err = CallArgumentError_NoneConstantParameter; + } + } } score += s; } |