Commit: patch 9.1.0989: Vim9: Whitespace after the final enum value causes a syntax error

6 views
Skip to first unread message

Christian Brabandt

unread,
Jan 4, 2025, 11:15:16 AM1/4/25
to vim...@googlegroups.com
patch 9.1.0989: Vim9: Whitespace after the final enum value causes a syntax error

Commit: https://github.com/vim/vim/commit/dbe39edb29cf5f899d475ee783a059cb6f678286
Author: Doug Kearns <dougk...@gmail.com>
Date: Sat Jan 4 17:12:24 2025 +0100

patch 9.1.0989: Vim9: Whitespace after the final enum value causes a syntax error

Problem: Vim9: Whitespace after the final enum value causes a syntax
error
Solution: Fix parsing to allow whitespace after the final enum value.
(Doug Kearns)

closes: #16383

Signed-off-by: Doug Kearns <dougk...@gmail.com>
Signed-off-by: Yegappan Lakshmanan <yega...@yahoo.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/testdir/test_codestyle.vim b/src/testdir/test_codestyle.vim
index 83f52ef34..51c1209d4 100644
--- a/src/testdir/test_codestyle.vim
+++ b/src/testdir/test_codestyle.vim
@@ -85,6 +85,7 @@ def Test_test_files()
&& fname !~ 'test_let.vim'
&& fname !~ 'test_tagjump.vim'
&& fname !~ 'test_vim9_cmd.vim'
+ && fname !~ 'test_vim9_enum.vim'
cursor(1, 1)
var lnum = search(
fname =~ 'test_vim9_assign.vim' ? '[^=]\s$'
diff --git a/src/testdir/test_vim9_enum.vim b/src/testdir/test_vim9_enum.vim
index a5fb26fcf..74eb46880 100644
--- a/src/testdir/test_vim9_enum.vim
+++ b/src/testdir/test_vim9_enum.vim
@@ -908,6 +908,18 @@ def Test_enum_comments()
END
v9.CheckSourceSuccess(lines)

+ lines =<< trim END
+ vim9script
+ enum Car # cars
+ # before enum
+ Honda(), # honda
+ # before enum
+ Ford() # ford
+ endenum
+ assert_equal(1, Car.Ford.ordinal)
+ END
+ v9.CheckSourceSuccess(lines)
+
# Test for using an unsupported comment
lines =<< trim END
vim9script
@@ -921,6 +933,29 @@ def Test_enum_comments()
v9.CheckSourceFailure(lines, 'E1170: Cannot use #{ to start a comment', 4)
enddef

+" Test trailing whitespace after enum values
+def Test_enum_whitespace()
+ var lines =<< trim END
+ vim9script
+ enum Car
+ Honda,
+ Ford
+ endenum
+ defcompile
+ END
+ v9.CheckSourceSuccess(lines)
+
+ lines =<< trim END
+ vim9script
+ enum Car
+ Honda(),
+ Ford()
+ endenum
+ defcompile
+ END
+ v9.CheckSourceSuccess(lines)
+enddef
+
" Test string() with enums
def Test_enum_string()
var lines =<< trim END
diff --git a/src/version.c b/src/version.c
index 987aa9b3f..99f41030f 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 989,
/**/
988,
/**/
diff --git a/src/vim9class.c b/src/vim9class.c
index 22db751e5..7c7700ba1 100644
--- a/src/vim9class.c
+++ b/src/vim9class.c
@@ -1623,6 +1623,8 @@ enum_parse_values(
}
}

+ p = skipwhite(p);
+
if (*p != NUL && *p != '#')
{
if (did_emsg == did_emsg_before)
Reply all
Reply to author
Forward
0 new messages