Skip to content

Commit 4a9967b

Browse files
h-eastchrisbra
authored andcommitted
patch 9.1.2049: Vim9: unexpected E1209 error
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>
1 parent 997952a commit 4a9967b

3 files changed

Lines changed: 26 additions & 12 deletions

File tree

src/eval.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6799,13 +6799,13 @@ var2fpos(
67996799
char_u *name;
68006800
static pos_T pos;
68016801
pos_T *pp;
6802+
int error = FALSE;
68026803

68036804
// Argument can be [lnum, col, coladd].
68046805
if (varp->v_type == VAR_LIST)
68056806
{
68066807
list_T *l;
68076808
int len;
6808-
int error = FALSE;
68096809
listitem_T *li;
68106810

68116811
l = varp->vval.v_list;
@@ -6857,11 +6857,16 @@ var2fpos(
68576857
if (name == NULL)
68586858
return NULL;
68596859

6860+
error = TRUE;
68606861
pos.lnum = 0;
6861-
if (name[0] == '.' && (!in_vim9script() || name[1] == NUL))
6862+
if (name[0] == '.')
68626863
{
6863-
// cursor
6864-
pos = curwin->w_cursor;
6864+
if (!in_vim9script() || name[1] == NUL)
6865+
{
6866+
error = FALSE;
6867+
// cursor
6868+
pos = curwin->w_cursor;
6869+
}
68656870
}
68666871
else if (name[0] == 'v' && name[1] == NUL)
68676872
{
@@ -6871,14 +6876,17 @@ var2fpos(
68716876
else
68726877
pos = curwin->w_cursor;
68736878
}
6874-
else if (name[0] == '\'' && (!in_vim9script()
6875-
|| (name[1] != NUL && name[2] == NUL)))
6879+
else if (name[0] == '\'')
68766880
{
6877-
// mark
6878-
pp = getmark_buf_fnum(curbuf, name[1], FALSE, fnum);
6879-
if (pp == NULL || pp == (pos_T *)-1 || pp->lnum <= 0)
6880-
return NULL;
6881-
pos = *pp;
6881+
if (!in_vim9script() || (name[1] != NUL && name[2] == NUL))
6882+
{
6883+
error = FALSE;
6884+
// mark
6885+
pp = getmark_buf_fnum(curbuf, name[1], FALSE, fnum);
6886+
if (pp == NULL || pp == (pos_T *)-1 || pp->lnum <= 0)
6887+
return NULL;
6888+
pos = *pp;
6889+
}
68826890
}
68836891
if (pos.lnum != 0)
68846892
{
@@ -6929,7 +6937,7 @@ var2fpos(
69296937
}
69306938
return &pos;
69316939
}
6932-
if (in_vim9script())
6940+
if (in_vim9script() && error)
69336941
semsg(_(e_invalid_value_for_line_number_str), name);
69346942
return NULL;
69356943
}

src/testdir/test_vim9_builtin.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,10 @@ def Test_col()
804804
v9.CheckSourceDefAndScriptFailure(['col(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1222: String or List required for argument 1'])
805805
v9.CheckSourceDefAndScriptFailure(['col(".", [])'], ['E1013: Argument 2: type mismatch, expected number but got list<any>', 'E1210: Number required for argument 2'])
806806
v9.CheckSourceDefExecAndScriptFailure(['col("")'], 'E1209: Invalid value for a line number')
807+
v9.CheckSourceDefExecAndScriptFailure(['col(".1")'], 'E1209: Invalid value for a line number')
808+
v9.CheckSourceDefAndScriptSuccess(['col(".")'])
809+
v9.CheckSourceDefExecAndScriptFailure(['col("\''a1")'], 'E1209: Invalid value for a line number')
810+
v9.CheckSourceDefAndScriptSuccess(['col("\''a")'])
807811
bw!
808812
enddef
809813

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,8 @@ static char *(features[]) =
734734

735735
static int included_patches[] =
736736
{ /* Add new patch number below this line */
737+
/**/
738+
2049,
737739
/**/
738740
2048,
739741
/**/

0 commit comments

Comments
 (0)