]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.2049: Vim9: unexpected E1209 error v9.1.2049
authorHirohito Higashi <h.east.727@gmail.com>
Sat, 3 Jan 2026 17:16:23 +0000 (17:16 +0000)
committerChristian Brabandt <cb@256bit.org>
Sat, 3 Jan 2026 17:16:23 +0000 (17:16 +0000)
Problem:  Vim9: unexpected E1209 error
Solution: Fix error message (Hirohito Higashi)

closes: #19067

Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/eval.c
src/testdir/test_vim9_builtin.vim
src/version.c

index 15ee3fe1107fa299fd63db8d6d87054dbf0ddc7f..254a0c608382809d6eb9d661d340b2bf50f8e0ed 100644 (file)
@@ -6799,13 +6799,13 @@ var2fpos(
     char_u             *name;
     static pos_T       pos;
     pos_T              *pp;
+    int                        error = FALSE;
 
     // Argument can be [lnum, col, coladd].
     if (varp->v_type == VAR_LIST)
     {
        list_T          *l;
        int             len;
-       int             error = FALSE;
        listitem_T      *li;
 
        l = varp->vval.v_list;
@@ -6857,11 +6857,16 @@ var2fpos(
     if (name == NULL)
        return NULL;
 
+    error = TRUE;
     pos.lnum = 0;
-    if (name[0] == '.' && (!in_vim9script() || name[1] == NUL))
+    if (name[0] == '.')
     {
-       // cursor
-       pos = curwin->w_cursor;
+       if (!in_vim9script() || name[1] == NUL)
+       {
+           error = FALSE;
+           // cursor
+           pos = curwin->w_cursor;
+       }
     }
     else if (name[0] == 'v' && name[1] == NUL)
     {
@@ -6871,14 +6876,17 @@ var2fpos(
        else
            pos = curwin->w_cursor;
     }
-    else if (name[0] == '\'' && (!in_vim9script()
-                                       || (name[1] != NUL && name[2] == NUL)))
+    else if (name[0] == '\'')
     {
-       // mark
-       pp = getmark_buf_fnum(curbuf, name[1], FALSE, fnum);
-       if (pp == NULL || pp == (pos_T *)-1 || pp->lnum <= 0)
-           return NULL;
-       pos = *pp;
+       if (!in_vim9script() || (name[1] != NUL && name[2] == NUL))
+       {
+           error = FALSE;
+           // mark
+           pp = getmark_buf_fnum(curbuf, name[1], FALSE, fnum);
+           if (pp == NULL || pp == (pos_T *)-1 || pp->lnum <= 0)
+               return NULL;
+           pos = *pp;
+       }
     }
     if (pos.lnum != 0)
     {
@@ -6929,7 +6937,7 @@ var2fpos(
        }
        return &pos;
     }
-    if (in_vim9script())
+    if (in_vim9script() && error)
        semsg(_(e_invalid_value_for_line_number_str), name);
     return NULL;
 }
index a07ba8c099bcf6d8e04b337ce5ec43aa0c0793cb..4346c14713b23aff54cac78d2ccebe63c11daf6b 100644 (file)
@@ -804,6 +804,10 @@ def Test_col()
   v9.CheckSourceDefAndScriptFailure(['col(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1222: String or List required for argument 1'])
   v9.CheckSourceDefAndScriptFailure(['col(".", [])'], ['E1013: Argument 2: type mismatch, expected number but got list<any>', 'E1210: Number required for argument 2'])
   v9.CheckSourceDefExecAndScriptFailure(['col("")'], 'E1209: Invalid value for a line number')
+  v9.CheckSourceDefExecAndScriptFailure(['col(".1")'], 'E1209: Invalid value for a line number')
+  v9.CheckSourceDefAndScriptSuccess(['col(".")'])
+  v9.CheckSourceDefExecAndScriptFailure(['col("\''a1")'], 'E1209: Invalid value for a line number')
+  v9.CheckSourceDefAndScriptSuccess(['col("\''a")'])
   bw!
 enddef
 
index 7375bfbb26b38ce989eac9d11eb4efe6907aca0b..8311522dfa68f63d251dc9bb046831336194e678 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2049,
 /**/
     2048,
 /**/