Skip to content

Commit dbe39ed

Browse files
dkearnschrisbra
authored andcommitted
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 <dougkearns@gmail.com> Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent cd96075 commit dbe39ed

4 files changed

Lines changed: 40 additions & 0 deletions

File tree

src/testdir/test_codestyle.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def Test_test_files()
8585
&& fname !~ 'test_let.vim'
8686
&& fname !~ 'test_tagjump.vim'
8787
&& fname !~ 'test_vim9_cmd.vim'
88+
&& fname !~ 'test_vim9_enum.vim'
8889
cursor(1, 1)
8990
var lnum = search(
9091
fname =~ 'test_vim9_assign.vim' ? '[^=]\s$'

src/testdir/test_vim9_enum.vim

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,18 @@ def Test_enum_comments()
908908
END
909909
v9.CheckSourceSuccess(lines)
910910

911+
lines =<< trim END
912+
vim9script
913+
enum Car # cars
914+
# before enum
915+
Honda(), # honda
916+
# before enum
917+
Ford() # ford
918+
endenum
919+
assert_equal(1, Car.Ford.ordinal)
920+
END
921+
v9.CheckSourceSuccess(lines)
922+
911923
# Test for using an unsupported comment
912924
lines =<< trim END
913925
vim9script
@@ -921,6 +933,29 @@ def Test_enum_comments()
921933
v9.CheckSourceFailure(lines, 'E1170: Cannot use #{ to start a comment', 4)
922934
enddef
923935

936+
" Test trailing whitespace after enum values
937+
def Test_enum_whitespace()
938+
var lines =<< trim END
939+
vim9script
940+
enum Car
941+
Honda,
942+
Ford
943+
endenum
944+
defcompile
945+
END
946+
v9.CheckSourceSuccess(lines)
947+
948+
lines =<< trim END
949+
vim9script
950+
enum Car
951+
Honda(),
952+
Ford()
953+
endenum
954+
defcompile
955+
END
956+
v9.CheckSourceSuccess(lines)
957+
enddef
958+
924959
" Test string() with enums
925960
def Test_enum_string()
926961
var lines =<< trim END

src/version.c

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

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
989,
707709
/**/
708710
988,
709711
/**/

src/vim9class.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,6 +1623,8 @@ enum_parse_values(
16231623
}
16241624
}
16251625

1626+
p = skipwhite(p);
1627+
16261628
if (*p != NUL && *p != '#')
16271629
{
16281630
if (did_emsg == did_emsg_before)

0 commit comments

Comments
 (0)