aboutsummaryrefslogtreecommitdiff
path: root/src/check_type.cpp
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2021-11-25 11:31:04 +0000
committerGitHub <noreply@github.com>2021-11-25 11:31:04 +0000
commit44897b5eace3327df93f431d4be33ad3e5fc3b0f (patch)
treeaf6fece596f38c24a2c611be4f1fd6edb52bef94 /src/check_type.cpp
parent1e453cf1d75d56a0f4a3b689a6428f90bed1477f (diff)
parent825548120484826f7de85fe2e8d346b22bf9d63c (diff)
Merge pull request #1334 from jockus/allow-enum-any-int
Allow enums to pass #any_int checks
Diffstat (limited to 'src/check_type.cpp')
-rw-r--r--src/check_type.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp
index b7feb562d..b4f30d2f0 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -1564,7 +1564,7 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is
p->flags &= ~FieldFlag_const;
}
if (p->flags&FieldFlag_any_int) {
- error(name, "'#const' can only be applied to variable fields");
+ error(name, "'#any_int' can only be applied to variable fields");
p->flags &= ~FieldFlag_any_int;
}
@@ -1614,7 +1614,7 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is
ok = false;
}
} else if (p->flags&FieldFlag_any_int) {
- if (!is_type_integer(op.type) || !is_type_integer(type)) {
+ if ((!is_type_integer(op.type) && !is_type_enum(op.type)) || (!is_type_integer(type) && !is_type_enum(type))) {
ok = false;
} else if (!check_is_castable_to(ctx, &op, type)) {
ok = false;
@@ -1684,7 +1684,7 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is
param->flags |= EntityFlag_AutoCast;
}
if (p->flags&FieldFlag_any_int) {
- if (!is_type_integer(param->type)) {
+ if (!is_type_integer(param->type) && !is_type_enum(param->type)) {
gbString str = type_to_string(param->type);
error(name, "A parameter with '#any_int' must be an integer, got %s", str);
gb_string_free(str);