Patch 9.0.1662
Problem:    Crash when using a class member twice. (Christian J. Robinson)
Solution:   Make a copy of the value.
Files:      src/vim9execute.c, src/testdir/test_vim9_class.vim


*** ../vim-9.0.1661/src/vim9execute.c   2023-05-23 14:48:39.108607655 +0100
--- src/vim9execute.c   2023-06-24 19:17:15.012972703 +0100
***************
*** 3967,3974 ****
                    if (GA_GROW_FAILS(&ectx->ec_stack, 1))
                        goto theend;
                    classmember_T *cm = &iptr->isn_arg.classmember;
!                   *STACK_TV_BOT(0) =
!                                   cm->cm_class->class_members_tv[cm->cm_idx];
                    ++ectx->ec_stack.ga_len;
                }
                break;
--- 3967,3974 ----
                    if (GA_GROW_FAILS(&ectx->ec_stack, 1))
                        goto theend;
                    classmember_T *cm = &iptr->isn_arg.classmember;
!                   copy_tv(cm->cm_class->class_members_tv + cm->cm_idx,
!                                                             STACK_TV_BOT(0));
                    ++ectx->ec_stack.ga_len;
                }
                break;
*** ../vim-9.0.1661/src/testdir/test_vim9_class.vim     2023-06-10 
16:45:09.406610435 +0100
--- src/testdir/test_vim9_class.vim     2023-06-24 19:15:11.668672241 +0100
***************
*** 838,843 ****
--- 838,860 ----
    END
    v9.CheckScriptSuccess(lines)
  
+   # using static class member twice
+   lines =<< trim END
+       vim9script
+ 
+       class HTML
+         static author: string = 'John Doe'
+ 
+         static def MacroSubstitute(s: string): string
+           return substitute(s, '{{author}}', author, 'gi')
+         enddef
+       endclass
+ 
+       assert_equal('some text', HTML.MacroSubstitute('some text'))
+       assert_equal('some text', HTML.MacroSubstitute('some text'))
+   END
+   v9.CheckScriptSuccess(lines)
+ 
    # access private member in lambda
    lines =<< trim END
        vim9script
*** ../vim-9.0.1661/src/version.c       2023-06-24 17:11:00.713077736 +0100
--- src/version.c       2023-06-24 18:51:51.519104089 +0100
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1662,
  /**/

-- 
Get a life?  What is the URL where it can be downloaded?

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20230624182258.468111C071C%40moolenaar.net.

Raspunde prin e-mail lui