diff options
author | Ernie Rael <errael@raelity.com> | 2023-12-12 16:58:00 +0100 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2023-12-12 16:58:00 +0100 |
commit | 2025af165ec68d831f0f0f668a3ceac3f39142ef (patch) | |
tree | beb22176d7d2fa61be4054de5a5830cb31b933eb /src/typval.c | |
parent | c1c3b83816c8e22c9a710fb0c0cebc180ee6ce1e (diff) |
patch 9.0.2160: instanceof() should use varargs as second argv9.0.2160
Problem: instanceof() should use varargs as second arg
Solution: Modify `instanceof()` to use varargs instead of list
Modify `instanceof()` to use varargs instead of list
Valid `instanceof()` arguments are `type`s. A `type` is not a value;
it cannot be added to a list.
This change is non-compatible with the current usage of instanceof;
but instanceof is relatively new and it's a trivial change.
fixes: #13421
closes: #13644
Signed-off-by: Ernie Rael <errael@raelity.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/typval.c')
-rw-r--r-- | src/typval.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/typval.c b/src/typval.c index 078e2eb058..65cd912c32 100644 --- a/src/typval.c +++ b/src/typval.c @@ -1014,16 +1014,19 @@ tv_class_alias(typval_T *tv) } /* - * Give an error and return FAIL unless "args[idx]" is a class or a list. + * Give an error and return FAIL unless "args[idx]" is a class + * or class typealias. */ int -check_for_class_or_list_arg(typval_T *args, int idx) +check_for_class_or_typealias_args(typval_T *args, int idx) { - if (args[idx].v_type != VAR_CLASS && args[idx].v_type != VAR_LIST - && !tv_class_alias(&args[idx])) + for (int i = idx; args[i].v_type != VAR_UNKNOWN; ++i) { - semsg(_(e_list_or_class_required_for_argument_nr), idx + 1); - return FAIL; + if (args[i].v_type != VAR_CLASS && !tv_class_alias(&args[idx])) + { + semsg(_(e_class_or_typealias_required_for_argument_nr), i + 1); + return FAIL; + } } return OK; } |