Mercurial > vim
changeset 25296:ec0421c25be9 v8.2.3185
patch 8.2.3185: Vim9: start of inline function found in comment line
Commit: https://github.com/vim/vim/commit/ac2cd2b08f0fd15e9c3759da043e9b28da80dca8
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jul 19 21:04:23 2021 +0200
patch 8.2.3185: Vim9: start of inline function found in comment line
Problem: Vim9: start of inline function found in comment line.
Solution: Do not check for inline function in comment line. (closes https://github.com/vim/vim/issues/8589)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 19 Jul 2021 21:15:04 +0200 |
parents | ff61999903e4 |
children | f5985274cf98 |
files | src/testdir/test_vim9_expr.vim src/userfunc.c src/version.c |
diffstat | 3 files changed, 24 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -2075,6 +2075,10 @@ def Test_expr7_lambda_block() }) assert_equal(['no', 'yes', 'no'], dll) + # ignored_inline(0, (_) => { + # echo 'body' + # }) + sandbox var Safe = (nr: number): number => { return nr + 7 }
--- a/src/userfunc.c +++ b/src/userfunc.c @@ -866,26 +866,29 @@ get_function_body( } } - // Check for nested inline function. - end = p + STRLEN(p) - 1; - while (end > p && VIM_ISWHITE(*end)) - --end; - if (end > p && *end == '{') + if (nesting_def[nesting] ? *p != '#' : *p != '"') { - --end; + // Not a comment line: check for nested inline function. + end = p + STRLEN(p) - 1; while (end > p && VIM_ISWHITE(*end)) --end; - if (end > p + 2 && end[-1] == '=' && end[0] == '>') + if (end > p && *end == '{') { - // found trailing "=> {", start of an inline function - if (nesting == MAX_FUNC_NESTING - 1) - emsg(_(e_function_nesting_too_deep)); - else + --end; + while (end > p && VIM_ISWHITE(*end)) + --end; + if (end > p + 2 && end[-1] == '=' && end[0] == '>') { - ++nesting; - nesting_def[nesting] = TRUE; - nesting_inline[nesting] = TRUE; - indent += 2; + // found trailing "=> {", start of an inline function + if (nesting == MAX_FUNC_NESTING - 1) + emsg(_(e_function_nesting_too_deep)); + else + { + ++nesting; + nesting_def[nesting] = TRUE; + nesting_inline[nesting] = TRUE; + indent += 2; + } } } }