[vim/vim] Vim9: first argument of "cursor()" cannot be of type "any" even when it's a number (#8610)

5 views
Skip to first unread message

lacygoill

unread,
Jul 22, 2021, 3:46:42 PM7/22/21
to vim/vim, Subscribed

Describe the bug

In Vim9 script, the first argument of cursor() cannot be of type any even when it's a number.

To Reproduce

Run this shell command:

vim -Nu NONE -S <(cat <<'EOF'
    vim9script
    g:lnum = 1
    def Func()
        cursor(g:lnum, 1)
    enddef
    defcompile
EOF
)

This error is raised:

E1013: Argument 1: type mismatch, expected number but got any

Expected behavior

No error is raised.

Environment

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

Additional context

Regression introduced in 8.2.3188.


At first, I wasn't sure it was a bug (see here for the rationale).

But since then, I've found out that the patch breaks too many functions in my config. I think any should be accepted at compile time.


If we use a global variable for the column index, rather than the line index, no error is raised:

vim9script
g:col = 1
def Func()
    cursor(1, g:col)
enddef
defcompile
echo 'no error'
no error

Which is inconsistent. Why an error for the first argument, but not the second one? They have the same type.


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

Yegappan Lakshmanan

unread,
Jul 23, 2021, 1:07:38 AM7/23/21
to vim_dev, reply+ACY5DGE64SWAR2TWLQ...@reply.github.com, vim/vim, Subscribed
Hi,

I have created PR 8611 with a fix for this issue along with other changes.

Regards,
Yegappan

vim-dev ML

unread,
Jul 23, 2021, 1:07:58 AM7/23/21
to vim/vim, vim-dev ML, Your activity

Hi,

On Thu, Jul 22, 2021 at 12:46 PM lacygoill ***@***.***>
wrote:

> *Describe the bug*

>
> In Vim9 script, the first argument of cursor() cannot be of type any even
> when it's a number.
>
> *To Reproduce*

>
> Run this shell command:
>
> vim -Nu NONE -S <(cat <<'EOF'
> vim9script
> g:lnum = 1
> def Func()
> cursor(g:lnum, 1)
> enddef
> defcompile
> EOF
> )
>
> This error is raised:
>
> E1013: Argument 1: type mismatch, expected number but got any
>
> *Expected behavior*
>
> No error is raised.
>
> *Environment*
>
> - Vim version: 8.2 Included patches: 1-3203
> - OS: Ubuntu 20.04.2 LTS
> - Terminal: XTerm(353)
>
> *Additional context*
>
> Regression introduced in 8.2.3188.
> ------------------------------

>
> At first, I wasn't sure it was a bug (see here for the rationale
> <https://github.com/vim/vim/issues/8602#issuecomment-885145463>).

>
> But since then, I've found out that the patch breaks too many functions in
> my config. I think any should be accepted at compile time.
> ------------------------------

>
> If we use a global variable for the column index, rather than the line
> index, no error is raised:
>
> vim9scriptg:col = 1def Func()
> cursor(1, g:col)enddefdefcompileecho 'no error'

>
> no error
>
> Which is inconsistent. Why an error for the first argument, but not the
> second one? They have the same type.
>
>
> I have created PR 8611 with a fix for this issue along with other changes.

Regards,
Yegappan

lacygoill

unread,
Jul 23, 2021, 2:44:04 PM7/23/21
to vim/vim, vim-dev ML, Comment

Probably fixed in 8.2.3206


You are receiving this because you commented.

lacygoill

unread,
Jul 23, 2021, 2:44:04 PM7/23/21
to vim/vim, vim-dev ML, Comment

Closed #8610.


You are receiving this because you commented.

Reply all
Reply to author
Forward
0 new messages