Describe the bug
In Vim9 script, the positions passed to matchaddpos() cannot be lists of numbers.
To Reproduce
Run this shell command:
vim -Nu NONE -S <(cat <<'EOF'
vim9script
def Func()
matchaddpos('ErrorMsg', [[1, 1]])
enddef
defcompile
EOF
)
E1013 is raised:
E1013: Argument 2: type mismatch, expected list<number> but got list<list<number>>
Expected behavior
No error is raised, because :help matchaddpos() documents that it is allowed to express a position via a list of numbers:
{pos} is a list of positions. Each position can be one of
these:
- A number. This whole line will be highlighted. The first
line has number 1.- A list with one number, e.g., [23]. The whole line with this
number will be highlighted.- A list with two numbers, e.g., [23, 11]. The first number is
the line number, the second one is the column number (first
column is 1, the value must correspond to the byte index as
|col()| would return). The character at this position will
be highlighted.- A list with three numbers, e.g., [23, 11, 3]. As above, but
the third number gives the length of the highlight in bytes.
Note that the help states that the type of a single position can be a list of numbers. But that does not mean that {pos} is limited to a simple list of numbers. That's because {pos} itself can be a list of several positions. IOW, {pos} can be a list of lists of numbers.
Environment
Additional context
Regression introduced in 8.2.3206.
No issue at the script level:
vim9script matchaddpos('ErrorMsg', [[1, 1]]) echo 'no error'
no error
Which is inconsistent.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.![]()
To be more clear, the 2nd argument of matchaddpos() can have the type list<number> or list<list<number>>. Currently, only the former is accepted at compile time; but the latter should be too.
To be more clear, the 2nd argument of
matchaddpos()can have the typelist<number>orlist<list<number>>. Currently, only the former is accepted at compile time; but the latter should be too.
Probably fixed in 8.2.3211
—
You are receiving this because you commented.