To: vim_dev@googlegroups.com Subject: Patch 9.0.1375 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1375 Problem: Crash when getting member of obj of unknown class. Solution: Check for NULL class and give an error message. (Ernie Rael, closes #12096) Files: src/errors.h, src/vim9expr.c, src/testdir/test_vim9_class.vim *** ../vim-9.0.1374/src/errors.h 2023-02-26 18:58:19.754802188 +0000 --- src/errors.h 2023-03-03 14:54:29.284086132 +0000 *************** *** 3452,3455 **** --- 3452,3457 ---- #ifdef FEAT_EVAL EXTERN char e_cannot_use_non_null_object[] INIT(= N_("E1362: Cannot use a non-null object")); + EXTERN char e_incomplete_type[] + INIT(= N_("E1363: Incomplete type")); #endif *** ../vim-9.0.1374/src/vim9expr.c 2023-02-21 12:38:46.827436713 +0000 --- src/vim9expr.c 2023-03-03 15:02:13.536616736 +0000 *************** *** 293,298 **** --- 293,305 ---- } } + if (cl == NULL) + { + // TODO: this should not give an error but be handled at runtime + emsg(_(e_incomplete_type)); + return FAIL; + } + ++*arg; char_u *name = *arg; char_u *name_end = find_name_end(name, NULL, NULL, FNE_CHECK_START); *** ../vim-9.0.1374/src/testdir/test_vim9_class.vim 2023-03-02 17:38:30.019743929 +0000 --- src/testdir/test_vim9_class.vim 2023-03-03 15:01:57.700598951 +0000 *************** *** 272,277 **** --- 272,296 ---- echo Colorscheme.new(bg).GetBackground() END v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected object but got object') + + # TODO: this should not give an error but be handled at runtime + lines =<< trim END + vim9script + + class Class + this.id: string + def Method1() + echo 'Method1' .. this.id + enddef + endclass + + var obj = null_object + def Func() + obj.Method1() + enddef + Func() + END + v9.CheckScriptFailure(lines, 'E1363:') enddef def Test_class_member_initializer() *** ../vim-9.0.1374/src/version.c 2023-03-03 12:26:11.557759297 +0000 --- src/version.c 2023-03-03 14:56:22.384217527 +0000 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1375, /**/ -- Don't be humble ... you're not that great. -- Golda Meir /// 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 ///