patch 9.1.0261: Vim9: protected class and funcrefs accessible outside the class
Problem: Vim9: protected class and funcrefs accessible outside the class
(Aliaksei Budavei)
Solution: Check if class and object funcrefs are protected
(Yegappan)
closes: #14407
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/userfunc.c b/src/userfunc.c
index ce144a3..9a30796 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -570,10 +570,16 @@
fp->uf_arg_types[i] = type;
if (i < fp->uf_args.ga_len
&& (type->tt_type == VAR_FUNC
- || type->tt_type == VAR_PARTIAL)
- && var_wrong_func_name(
- ((char_u **)fp->uf_args.ga_data)[i], TRUE))
- return FAIL;
+ || type->tt_type == VAR_PARTIAL))
+ {
+ char_u *name = ((char_u **)fp->uf_args.ga_data)[i];
+ if (obj_members != NULL && *name == '_')
+ // protected object method
+ name++;
+
+ if (var_wrong_func_name(name, TRUE))
+ return FAIL;
+ }
}
}
}