[vim/vim] Vim9: cannot pass argument of type "any" to "popup_create()" (#8550)

8 views
Skip to first unread message

lacygoill

unread,
Jul 11, 2021, 2:34:32 PM7/11/21
to vim/vim, Subscribed

Describe the bug

In Vim9 script, we cannot pass an argument of type any to popup_create().

To Reproduce

Run this shell command:

vim -Nu NONE -S <(cat <<'EOF'
    vim9script
    def Func()
        var what: any = ''
        popup_create(what, {})
    enddef
    defcompile
EOF
)

This error is given:

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

Expected behavior

No error is given.

Environment

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

Additional context

The {what} argument of popup_create() can be many things; including a number or a string. Thus, it makes sense to use a variable of type any for the first argument of popup_create().


No error is given at the script level:

vim9script
vim9script
var what: any = ''
popup_create(what, {})
echo 'no error'
no error

Which is inconsistent.


If we give a number in compiled code, no error is given:

vim9script
def Func()
    popup_create(123, {})
enddef
defcompile
echo 'no error'
no error

It means that Vim is ok with us giving a number to popup_create(). But that's not what the first error message said:

E1013: Argument 1: type mismatch, expected string but got any
                                  ^-------------^


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 11, 2021, 3:19:47 PM7/11/21
to vim_dev, reply+ACY5DGD2F2GJRJB5GN...@reply.github.com, vim/vim, Subscribed
Hi,

I have created PR #8551 to address this issue.

Regards,
Yegappan

vim-dev ML

unread,
Jul 11, 2021, 3:20:05 PM7/11/21
to vim/vim, vim-dev ML, Your activity

Hi,

On Sun, Jul 11, 2021 at 11:34 AM lacygoill ***@***.***>
wrote:

> *Describe the bug*

>
> In Vim9 script, we cannot pass an argument of type any to popup_create().
>
> *To Reproduce*

>
> Run this shell command:
>
> vim -Nu NONE -S <(cat <<'EOF'
> vim9script
> def Func()
> var what: any = ''
> popup_create(what, {})
> enddef
> defcompile
> EOF
> )
>
> This error is given:
>
> E1013: Argument 1: type mismatch, expected string but got any
>
> *Expected behavior*
>
> No error is given.
>
> *Environment*
>
> - Vim version: 8.2 Included patches: 1-3151
> - OS: Ubuntu 20.04.2 LTS
> - Terminal: XTerm(353)
>
> *Additional context*

>
> The {what} argument of popup_create() can be many things; including a
> number or a string. Thus, it makes sense to use a variable of type any
> for the first argument of popup_create().
> ------------------------------

>
> No error is given at the script level:
>
> vim9scriptvim9scriptvar what: any = ''popup_create(what, {})echo 'no error'

>
> no error
>
> Which is inconsistent.
> ------------------------------

>
> If we give a number in compiled code, no error is given:
>
> vim9scriptdef Func()
> popup_create(123, {})enddefdefcompileecho 'no error'

>
> no error
>
> It means that Vim is ok with us giving a number to popup_create(). But
> that's not what the first error message said:
>
> E1013: Argument 1: type mismatch, expected string but got any
> ^-------------^
>
>
>
I have created PR #8551 to address this issue.

Regards,
Yegappan

Bram Moolenaar

unread,
Jul 11, 2021, 4:04:49 PM7/11/21
to vim/vim, vim-dev ML, Comment

Closed #8550 via 841e498.


You are receiving this because you commented.

Reply all
Reply to author
Forward
0 new messages