[vim/vim] Vim9: cannot call global function with `call()` in `:def` function without quotes (Issue #9826)

25 views
Skip to first unread message

lacygoill

unread,
Feb 22, 2022, 1:25:24 PM2/22/22
to vim/vim, Subscribed

Steps to reproduce

Run this shell command:

vim -Nu NONE -S <(tee <<'EOF'
    vim9script
    def Outer()
        def g:Inner()
            echomsg 'from g:Inner()'
        enddef
        call(g:Inner, [])
    enddef
    Outer()
EOF
)

E121 is given:

E121: Undefined variable: g:Inner

Expected behavior

No error is given. from g:Inner() is echo'ed.

Version of Vim

8.2 Included patches: 1-4442

Environment

Operating system: Ubuntu 20.04.4 LTS
Terminal: xterm
Value of $TERM: xterm-256color
Shell: zsh 5.8

Additional context

We don't need quotes if Inner() is turned into a function-local function:

vim9script
def Outer()
    def Inner()
        echomsg 'from Inner()'
    enddef
    call(Inner, [])
enddef
Outer()
from Inner()

And we don't need quotes if g:Inner() is called at the script level:

vim9script
def g:Inner()
    echomsg 'from g:Inner()'
enddef
call(g:Inner, [])
from g:Inner()

This is inconsistent. If we don't need quotes in these snippets, why should we need them in the first one?


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9826@github.com>

Bram Moolenaar

unread,
Feb 22, 2022, 2:40:01 PM2/22/22
to vim/vim, Subscribed

Closed #9826 via fe73255.


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/9826/issue_event/6120516851@github.com>

Reply all
Reply to author
Forward
0 new messages