[vim/vim] Inconsistent behavior of func/var autoloading (Issue #18858)

0 views
Skip to first unread message

Tyler Carbone

unread,
3:16 PM (1 hour ago) 3:16 PM
to vim/vim, Subscribed
twcarbone created an issue (vim/vim#18858)

I am studying the vim runtime system. As an exercise in package management, I placed the dracula colorscheme in pack/thirdparty/opt/vim-dracula of my 'runtimepath'.

The following sequence behaves not according to my (initial) understanding of optional packages and autoloads:

:colorscheme dracula  " error (expected - haven't loaded the package, yet)
:packadd vim-dracula
:colorscheme dracula  " still gives error (unexpected - I added the package?)

I experimented more with a dummy package:

" pack/thirdparty/opt/test/autoload/foo.vim

let g:foo#bar = 'bar'

function foo#baz()
    return 'baz'
endfunction

Specifically, the function call works after loading the package, but the global var does not.

:echo foo#bar    " error
:echo foo#baz()  " error
:packadd test
:echo foo#bar    " still error
:echo foo#baz()  " no error this time

The function is loaded by src/userfunc.c:3947 passing TRUE to script_autoload(...).

The global var is loaded by src/evalvars.c:3474 passing FALSE to script_autoload(...). Changing to TRUE fixes the issue, but the comment suggests FALSE was intentional "otherwise it would be loaded every time when checking if a function name is a Funcref variable".

Is this in fact the desired behavior? That is, the path to an autoloaded global variable is never re-checked, but a function is?

Ubuntu 22.04.5
Vim 9.1.0698


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/18858@github.com>

Reply all
Reply to author
Forward
0 new messages