Mercurial > vim
comparison src/typval.c @ 33924:ccdb948c7273 v9.0.2160
patch 9.0.2160: instanceof() should use varargs as second arg
Commit: https://github.com/vim/vim/commit/2025af165ec68d831f0f0f668a3ceac3f39142ef
Author: Ernie Rael <errael@raelity.com>
Date: Tue Dec 12 16:58:00 2023 +0100
patch 9.0.2160: instanceof() should use varargs as second arg
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>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 12 Dec 2023 17:15:03 +0100 |
parents | f126ffc85f7c |
children | ab6a70fad5b5 |
comparison
equal
deleted
inserted
replaced
33923:b1e48fed6e55 | 33924:ccdb948c7273 |
---|---|
1012 return tv->v_type == VAR_TYPEALIAS && | 1012 return tv->v_type == VAR_TYPEALIAS && |
1013 tv->vval.v_typealias->ta_type->tt_type == VAR_OBJECT; | 1013 tv->vval.v_typealias->ta_type->tt_type == VAR_OBJECT; |
1014 } | 1014 } |
1015 | 1015 |
1016 /* | 1016 /* |
1017 * Give an error and return FAIL unless "args[idx]" is a class or a list. | 1017 * Give an error and return FAIL unless "args[idx]" is a class |
1018 */ | 1018 * or class typealias. |
1019 int | 1019 */ |
1020 check_for_class_or_list_arg(typval_T *args, int idx) | 1020 int |
1021 { | 1021 check_for_class_or_typealias_args(typval_T *args, int idx) |
1022 if (args[idx].v_type != VAR_CLASS && args[idx].v_type != VAR_LIST | 1022 { |
1023 && !tv_class_alias(&args[idx])) | 1023 for (int i = idx; args[i].v_type != VAR_UNKNOWN; ++i) |
1024 { | 1024 { |
1025 semsg(_(e_list_or_class_required_for_argument_nr), idx + 1); | 1025 if (args[i].v_type != VAR_CLASS && !tv_class_alias(&args[idx])) |
1026 return FAIL; | 1026 { |
1027 semsg(_(e_class_or_typealias_required_for_argument_nr), i + 1); | |
1028 return FAIL; | |
1029 } | |
1027 } | 1030 } |
1028 return OK; | 1031 return OK; |
1029 } | 1032 } |
1030 | 1033 |
1031 /* | 1034 /* |