mirror of
https://github.com/odin-lang/Odin.git
synced 2026-10-12 19:19:53 -04:00
Add proc(#const x: Type) to enforce a constant parameter (but not polymorphic) to a procedure
This commit is contained in:
1 parent
1596bca92d
commit
3d74c2f6c0
5 files changed
+33
-2
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user