Skip to content

Commit 4bba16d

Browse files
committed
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.
1 parent b033ee2 commit 4bba16d

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/testdir/test_vim9_func.vim

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,17 @@ def Test_nested_function()
630630
assert_equal(2, Test())
631631
END
632632
CheckScriptSuccess(lines)
633+
634+
lines =<< trim END
635+
vim9script
636+
def Outer()
637+
def Inner()
638+
echo 'hello'
639+
enddef burp
640+
enddef
641+
defcompile
642+
END
643+
CheckScriptFailure(lines, 'E1173: Text found after enddef: burp', 3)
633644
enddef
634645

635646
def Test_not_nested_function()

src/userfunc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,8 @@ get_function_body(
822822
else if (*p != NUL && *p != (vim9_function ? '#' : '"')
823823
&& (vim9_function || p_verbose > 0))
824824
{
825+
SOURCING_LNUM = sourcing_lnum_top
826+
+ newlines->ga_len + 1;
825827
if (eap->cmdidx == CMD_def)
826828
semsg(_(e_text_found_after_enddef_str), p);
827829
else

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3352,
758760
/**/
759761
3351,
760762
/**/

0 commit comments

Comments
 (0)