# HG changeset patch # User Bram Moolenaar # Date 1610139604 -3600 # Node ID 987fb6e8a376edcdc09f2d3bcec133cf577a7c2e # Parent f1518df5eefac236a1e1e5bb5de932b29657de99 patch 8.2.2315: Vim9: "enddef" as dict key misintepreted as function end Commit: https://github.com/vim/vim/commit/832ea89ca90cdff019ee7cf31d5c44bfa164313a Author: Bram Moolenaar Date: Fri Jan 8 21:55:26 2021 +0100 patch 8.2.2315: Vim9: "enddef" as dict key misintepreted as function end Problem: Vim9: "enddef" as dict key misintepreted as function end. Solution: Check for following colon. (closes https://github.com/vim/vim/issues/7640) diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -116,6 +116,14 @@ def Test_missing_endfunc_enddef() 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 diff --git a/src/userfunc.c b/src/userfunc.c --- a/src/userfunc.c +++ b/src/userfunc.c @@ -3444,8 +3444,10 @@ define_function(exarg_T *eap, char_u *na ; // 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)) + ? "enddef" : "endfunction", 4) + && *p != ':') { if (nesting-- == 0) { @@ -3484,7 +3486,7 @@ define_function(exarg_T *eap, char_u *na // not find it. else if (nesting_def[nesting]) { - if (checkforcmd(&p, "endfunction", 4)) + if (checkforcmd(&p, "endfunction", 4) && *p != ':') emsg(_(e_mismatched_endfunction)); } else if (eap->cmdidx == CMD_def && checkforcmd(&p, "enddef", 4)) diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2315, +/**/ 2314, /**/ 2313,