diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-12-20 13:38:22 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-12-20 13:38:22 +0000 |
commit | 418b54788106efd94bbc71a4b100afae1080cbfc (patch) | |
tree | cf6adaa37e7d2727993fcdf0e6142b0a4ebc1737 | |
parent | 104b2ff4d0ec9248ba0b979aa3bbccb65fcad422 (diff) | |
download | vim-git-418b54788106efd94bbc71a4b100afae1080cbfc.tar.gz |
patch 9.0.1083: empty and comment lines in a class cause an errorv9.0.1083
Problem: Empty and comment lines in a class cause an error.
Solution: Skip empty and comment lines. (closes #11734)
-rw-r--r-- | src/testdir/test_vim9_class.vim | 2 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9class.c | 10 |
3 files changed, 14 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_class.vim b/src/testdir/test_vim9_class.vim index 5ec606e09..f45e3fa6c 100644 --- a/src/testdir/test_vim9_class.vim +++ b/src/testdir/test_vim9_class.vim @@ -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 diff --git a/src/version.c b/src/version.c index 4baa1b39b..877fe752d 100644 --- a/src/version.c +++ b/src/version.c @@ -696,6 +696,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1083, +/**/ 1082, /**/ 1081, diff --git a/src/vim9class.c b/src/vim9class.c index a91a4a5d5..94fe9e227 100644 --- a/src/vim9class.c +++ b/src/vim9class.c @@ -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)) { |