To: vim_dev@googlegroups.com Subject: Patch 8.2.2315 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2315 Problem: Vim9: "enddef" as dict key misintepreted as function end. Solution: Check for following colon. (closes #7640) Files: src/userfunc.c, src/testdir/test_vim9_func.vim *** ../vim-8.2.2314/src/userfunc.c 2021-01-07 19:23:04.966566919 +0100 --- src/userfunc.c 2021-01-08 21:50:52.838153028 +0100 *************** *** 3444,3451 **** ; // Check for "endfunction" or "enddef". if (checkforcmd(&p, nesting_def[nesting] ! ? "enddef" : "endfunction", 4)) { if (nesting-- == 0) { --- 3444,3453 ---- ; // Check for "endfunction" or "enddef". + // When a ":" follows it must be a dict key; "enddef: value," if (checkforcmd(&p, nesting_def[nesting] ! ? "enddef" : "endfunction", 4) ! && *p != ':') { if (nesting-- == 0) { *************** *** 3484,3490 **** // not find it. else if (nesting_def[nesting]) { ! if (checkforcmd(&p, "endfunction", 4)) emsg(_(e_mismatched_endfunction)); } else if (eap->cmdidx == CMD_def && checkforcmd(&p, "enddef", 4)) --- 3486,3492 ---- // not find it. else if (nesting_def[nesting]) { ! if (checkforcmd(&p, "endfunction", 4) && *p != ':') emsg(_(e_mismatched_endfunction)); } else if (eap->cmdidx == CMD_def && checkforcmd(&p, "enddef", 4)) *** ../vim-8.2.2314/src/testdir/test_vim9_func.vim 2021-01-07 19:23:04.966566919 +0100 --- src/testdir/test_vim9_func.vim 2021-01-08 21:49:51.522334078 +0100 *************** *** 116,121 **** --- 116,129 ---- CheckScriptFailure(lines, 'E126:', 2) enddef + def Test_enddef_dict_key() + var d = { + enddef: 'x', + endfunc: 'y', + } + assert_equal({enddef: 'x', endfunc: 'y'}, d) + enddef + def ReturnString(): string return 'string' enddef *** ../vim-8.2.2314/src/version.c 2021-01-08 20:53:05.736404852 +0100 --- src/version.c 2021-01-08 21:48:44.238534267 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2315, /**/ -- hundred-and-one symptoms of being an internet addict: 114. You are counting items, you go "0,1,2,3,4,5,6,7,8,9,A,B,C,D...". /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///