]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1083: empty and comment lines in a class cause an error v9.0.1083
authorBram Moolenaar <Bram@vim.org>
Tue, 20 Dec 2022 13:38:22 +0000 (13:38 +0000)
committerBram Moolenaar <Bram@vim.org>
Tue, 20 Dec 2022 13:38:22 +0000 (13:38 +0000)
Problem:    Empty and comment lines in a class cause an error.
Solution:   Skip empty and comment lines. (closes #11734)

src/testdir/test_vim9_class.vim
src/version.c
src/vim9class.c

index 5ec606e0969caffa40e93282a05927facbb14269..f45e3fa6c8cde887129f3278eb2c069b47ab0bea 100644 (file)
@@ -131,6 +131,7 @@ def Test_class_basic()
         this.lnum: number
         this.col: number
 
+        # make a nicely formatted string
         def ToString(): string
           return $'({this.lnum}, {this.col})'
         enddef
@@ -155,6 +156,7 @@ def Test_class_member_initializer()
         this.lnum: number = 1
         this.col: number = 1
 
+        # constructor with only the line number
         def new(lnum: number)
           this.lnum = lnum
         enddef
index 4baa1b39b01dbb4d42630820198e9edf83fcff38..877fe752da1725f39a22e85946cd74f856b8c222 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1083,
 /**/
     1082,
 /**/
index a91a4a5d5c92dfcb998c054d81280765f093d80e..94fe9e227c207be5e840c4c5ec99f3eded84a086 100644 (file)
@@ -248,6 +248,16 @@ ex_class(exarg_T *eap)
            break;
        char_u *line = skipwhite(theline);
 
+       // Skip empty and comment lines.
+       if (*line == NUL)
+           continue;
+       if (*line == '#')
+       {
+           if (vim9_bad_comment(line))
+               break;
+           continue;
+       }
+
        char_u *p = line;
        if (checkforcmd(&p, "endclass", 4))
        {