]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0378: Vim9: no comments allowed after class vars v9.1.0378
authorYegappan Lakshmanan <yegappan@yahoo.com>
Sun, 28 Apr 2024 07:54:09 +0000 (09:54 +0200)
committerChristian Brabandt <cb@256bit.org>
Sun, 28 Apr 2024 07:54:09 +0000 (09:54 +0200)
Problem:  Vim9: no comments allowed after class vars
          (Christian Robinson, after 9.1.376)
Solution: Allow trailing comments after class vars
          (Yegappan Lakshmanan)

closes: #14651

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/testdir/test_vim9_class.vim
src/version.c
src/vim9class.c

index bd06c6e28622ec58e4f96fc8cd2b6e832a0f67ef..ed3aac0be2978a1b70b92d1cc039321e40a107ed 100644 (file)
@@ -103,6 +103,18 @@ def Test_class_basic()
   END
   v9.CheckSourceFailure(lines, "E488: Trailing characters: | var y = 10", 3)
 
+  # Comments are allowed after an inline block
+  lines =<< trim END
+    vim9script
+    class Foo
+      static const bar = { # {{{
+        baz: 'qux'
+      } # }}}
+    endclass
+    assert_equal({baz: 'qux'}, Foo.bar)
+  END
+  v9.CheckSourceSuccess(lines)
+
   # Try to define a class with the same name as an existing variable
   lines =<< trim END
     vim9script
index 71e56a223f7e78f6f39ae1e41adfdce54533c6fd..be2be7062b679089604a9bb2f38b2a32a5d18cdd 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    378,
 /**/
     377,
 /**/
index 4314b52901d6799424eaa0d1000b82fbd19904eb..21945fec348e1eebf1ae9e06f5f46532b72083b8 100644 (file)
@@ -137,7 +137,7 @@ parse_member(
        (void)skip_expr_concatenate(&init_arg, &expr_start, &expr_end, &evalarg);
 
        init_arg = skipwhite(init_arg);
-       if (*init_arg != NUL)
+       if (*init_arg != NUL && !vim9_comment_start(init_arg))
        {
            semsg(_(e_trailing_characters_str), init_arg);
            return FAIL;