To: vim_dev@googlegroups.com Subject: Patch 9.0.1662 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ 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 -- Bram@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 ///