Hi,

On Mon, Aug 28, 2023 at 6:47 PM errael <[email protected]> wrote:

> I looked around to get a feel... The following fixes the "access to
> private static" var in the example, if you want to include it. Not tested
> much.
>
> diff --git a/src/vim9expr.c b/src/vim9expr.c
> --- a/src/vim9expr.c
> +++ b/src/vim9expr.c
> @@ -434,14 +434,25 @@
>      {
>         // load class member
>         int idx;
> +       ocmember_T *m;
>         for (idx = 0; idx < cl->class_class_member_count; ++idx)
>         {
> -           ocmember_T *m = &cl->class_class_members[idx];
> +           m = &cl->class_class_members[idx];
>             if (STRNCMP(name, m->ocm_name, len) == 0 && m->ocm_name[len] == 
> NUL)
>                 break;
>         }
>         if (idx < cl->class_class_member_count)
>         {
> +           // TODO: Would kindof prefer (@yegappan what do you think)
> +           //       even though it's more likely to get a cache miss.
> +           // if (m->ocm_access == VIM_ACCESS_PRIVATE
> +           //                                      && !inside_class(cctx, 
> cl))
> +           // Maybe not, *name == '_' is simple to look at but...
> +           if (*name == '_' && !inside_class(cctx, cl))
> +           {
> +               semsg(_(e_cannot_access_private_member_str), m->ocm_name);
> +               return FAIL;
> +           }
>             *arg = name_end;
>             return generate_CLASSMEMBER(cctx, TRUE, cl, idx);
>         }
>
>
>
This is the proper fix for this issue.  A similar check is used before this
block of code for
readonly object members.  Can you open a PR for this with a test for this
condition?

- Yegappan

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/CAAW7x7mV2%2BnFUS2w1rkmwHJgU2tPoL4WR9pLj9HTZ1xobN-M6w%40mail.gmail.com.

Raspunde prin e-mail lui