[vim/vim] Vim9: matchaddpos() positions cannot be lists of numbers (#8617)

4 views
Skip to first unread message

lacygoill

unread,
Jul 23, 2021, 3:02:21 PM7/23/21
to vim/vim, Subscribed

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

  • Vim version: 8.2 Included patches: 1-3206
  • OS: Ubuntu 20.04.2 LTS
  • Terminal: XTerm(353)

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.


cc @yegappan via #8611


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

lacygoill

unread,
Jul 23, 2021, 3:12:51 PM7/23/21
to vim/vim, Subscribed

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.

Yegappan Lakshmanan

unread,
Jul 24, 2021, 2:19:00 AM7/24/21
to vim_dev, reply+ACY5DGEN4NFLC4FJHE...@reply.github.com, vim/vim, Subscribed
Hi,

On Fri, Jul 23, 2021 at 12:12 PM lacygoill <vim-dev...@256bit.org> wrote:

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.



Thanks for reporting the issue. I have created PR 8610 with a fix
for this issue along with other changes.

- Yegappan

vim-dev ML

unread,
Jul 24, 2021, 2:19:18 AM7/24/21
to vim/vim, vim-dev ML, Your activity

Hi,

On Fri, Jul 23, 2021 at 12:12 PM lacygoill ***@***.***>

wrote:

> 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.
>
>
>
Thanks for reporting the issue. I have created PR 8610 with a fix
for this issue along with other changes.

- Yegappan

lacygoill

unread,
Jul 24, 2021, 10:20:07 AM7/24/21
to vim/vim, vim-dev ML, Comment

Closed #8617.


You are receiving this because you commented.

lacygoill

unread,
Jul 24, 2021, 10:20:07 AM7/24/21
to vim/vim, vim-dev ML, Comment

Probably fixed in 8.2.3211


You are receiving this because you commented.

Reply all
Reply to author
Forward
0 new messages