patch 9.1.0226: Not able to assign enum values to an enum static variable Commit: https://github.com/vim/vim/commit/abedca96efa76db2bba74a5264df632da862203d Author: Yegappan Lakshmanan <yegap...@yahoo.com> Date: Fri Mar 29 10:08:23 2024 +0100
patch 9.1.0226: Not able to assign enum values to an enum static variable Problem: Not able to assign enum values to an enum static variable (zzzyxwvut) Solution: Make it work (Yegappan Lakshmanan) related: #14224 closes: #14329 Signed-off-by: Yegappan Lakshmanan <yegap...@yahoo.com> Signed-off-by: Christian Brabandt <c...@256bit.org> diff --git a/src/testdir/test_vim9_enum.vim b/src/testdir/test_vim9_enum.vim index 6e10e0c70..ceea32fe4 100644 --- a/src/testdir/test_vim9_enum.vim +++ b/src/testdir/test_vim9_enum.vim @@ -964,7 +964,7 @@ def Test_enum_refcount() enum Star Gemini, - Orion, + Orion endenum assert_equal(3, test_refcount(Star)) assert_equal(2, test_refcount(Star.Gemini)) @@ -1473,4 +1473,17 @@ def Test_enum_eval() v9.CheckSourceSuccess(lines) enddef +" Test for using "values" in an enum class variable +def Test_use_enum_values_in_class_variable() + var lines =<< trim END + vim9script + enum Dir + North, South + static const dirs: list<Dir> = Dir.values + endenum + assert_equal([Dir.North, Dir.South], Dir.dirs) + END + v9.CheckSourceSuccess(lines) +enddef + " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker diff --git a/src/version.c b/src/version.c index e96f17c25..b56b6d38d 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 */ +/**/ + 226, /**/ 225, /**/ diff --git a/src/vim9class.c b/src/vim9class.c index 696349190..2d60ba95a 100644 --- a/src/vim9class.c +++ b/src/vim9class.c @@ -2056,6 +2056,11 @@ early_ret: if (enum_parse_values(eap, cl, line, &classmembers, &num_enum_values, &enum_end) == FAIL) break; + + if (enum_end) + // Add the enum "values" class variable. + enum_add_values_member(cl, &classmembers, num_enum_values, + &type_list); continue; } @@ -2368,9 +2373,9 @@ early_ret: vim_free(theline); - if (success && is_enum) - // Add the enum "values" class variable. - enum_add_values_member(cl, &classmembers, num_enum_values, &type_list); + if (success && is_enum && num_enum_values == 0) + // Empty enum statement. Add an empty "values" class variable + enum_add_values_member(cl, &classmembers, 0, &type_list); /* * Check a few things -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/E1rq8KJ-00DM6t-6m%40256bit.org.