# HG changeset patch # User Bram Moolenaar # Date 1629048603 -7200 # Node ID c204815f3058628f3720c4f73c8e0dc7937d9d5a # Parent 592a92a4d2210970d566b13d3c6a1a987d2eff8b patch 8.2.3352: Vim9: error for nested :enddef has wrong line number Commit: https://github.com/vim/vim/commit/4bba16d252da6f072d311f9b3ebb50101d6d2eaf Author: Bram Moolenaar Date: Sun Aug 15 19:28:05 2021 +0200 patch 8.2.3352: Vim9: error for nested :enddef has wrong line number Problem: Vim9: error for nested :enddef has wrong line number. Solution: Compute the line number. 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 @@ -630,6 +630,17 @@ def Test_nested_function() assert_equal(2, Test()) END CheckScriptSuccess(lines) + + lines =<< trim END + vim9script + def Outer() + def Inner() + echo 'hello' + enddef burp + enddef + defcompile + END + CheckScriptFailure(lines, 'E1173: Text found after enddef: burp', 3) enddef def Test_not_nested_function() diff --git a/src/userfunc.c b/src/userfunc.c --- a/src/userfunc.c +++ b/src/userfunc.c @@ -822,6 +822,8 @@ get_function_body( else if (*p != NUL && *p != (vim9_function ? '#' : '"') && (vim9_function || p_verbose > 0)) { + SOURCING_LNUM = sourcing_lnum_top + + newlines->ga_len + 1; if (eap->cmdidx == CMD_def) semsg(_(e_text_found_after_enddef_str), p); else diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -756,6 +756,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3352, +/**/ 3351, /**/ 3350,