vim-patch:8.2.2671: error for line number in legacy script

Problem:    Error for line number in legacy script.
Solution:   Check for number type.
f6bdd82c7e

N/A patches for version.c:

vim-patch:8.2.2670: Vim9: error for append(0, text)

Problem:    Vim9: error for append(0, text).
Solution:   Check for negative number. (closes vim/vim#8022)
b2ac7d0663
This commit is contained in:
zeertzjq 2022-10-10 21:17:17 +08:00
parent 9c272b75ec
commit 5c9f6bdd8c

View File

@ -3751,8 +3751,9 @@ linenr_T tv_get_lnum(const typval_T *const tv)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
{ {
linenr_T lnum = (linenr_T)tv_get_number_chk(tv, NULL); linenr_T lnum = (linenr_T)tv_get_number_chk(tv, NULL);
if (lnum <= 0) { // No valid number, try using same function as line() does. if (lnum <= 0 && tv->v_type != VAR_NUMBER) {
int fnum; int fnum;
// No valid number, try using same function as line() does.
pos_T *const fp = var2fpos(tv, true, &fnum, false); pos_T *const fp = var2fpos(tv, true, &fnum, false);
if (fp != NULL) { if (fp != NULL) {
lnum = fp->lnum; lnum = fp->lnum;