[vim/vim] cannot find script local func (Issue #9820)

10 views
Skip to first unread message

Shane-XB-Qian

unread,
Feb 22, 2022, 6:18:15 AM2/22/22
to vim/vim, Subscribed

Steps to reproduce

function! s:watch_callback(...) abort
  let s:timer = timer_start(
        \ g:foo#update_interval,
        \ function('s:watch_callback')
        \)
endfunction

something script local func in one legacy vim script plugin in autoload,
then while you playing vim in some seconds later:
E117: Unknown function: <SNR>80_watch_callback

Expected behaviour

no err.
not sure if you can reprocedure it (i cannot minimal case it too),
and not sure if it was a corner case after 8.2.4429,
there were some weird case in recent change/patches,
e.g with or without single quote to function('FooFunc') vs function(FooFunc) was a matter?

// if it can be addressed then ok, or waiting someone else to simply it.

Version of Vim

8.2.4436

Environment

linux

Logs and stack traces

No response


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/9820@github.com>

lacygoill

unread,
Feb 22, 2022, 7:02:59 AM2/22/22
to vim/vim, Subscribed

There always had issues with script-local callback functions. They seem to be all fixed since a recent patch. I guess it's thanks to 8.2.4429.

I had a dozen snippets which gave different results; some of them gave the error you report. All of them are working fine now.


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/9820/1047726108@github.com>

Shane-XB-Qian

unread,
Feb 22, 2022, 7:08:03 AM2/22/22
to vim/vim, Subscribed

patch 8.2.4429 should be from the case i chatted with yegappan in one lsp plugin ticket.
but i guess it didnot or make new issue like this, notice here s:watch_callback the outter func name is same str in inner function('s:watch_callback') of timer_start(), maybe that's a corner case which was not noticed?


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/9820/1047730274@github.com>

Bram Moolenaar

unread,
Feb 22, 2022, 7:55:58 AM2/22/22
to vim/vim, Subscribed

I tried to reproduce it with this script:

function s:watch_callback(...) abort
  if a:0 == 0
    let s:timer = timer_start
(
	  \ 2000,
	  
\ function('s:watch_callback')
	  \)
  else
    echomsg 'called'
  endif
endfunction

call s:watch_callback()

But it works fine. Please try to come up with a reproduction script.


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/9820/1047768541@github.com>

Shane-XB-Qian

unread,
Feb 22, 2022, 8:06:05 AM2/22/22
to vim/vim, Subscribed

that func should be in a autoload fs, then in plugin registers a init call foo#watch() to call that func:

function! foo#watch() abort
  let s:timer = timer_start(0, function('s:watch_callback'))
endfunction

perhaps can be using tpop's pathogen to test that.
// but yea, i am not sure if that's a minimal case which to be reproduce, or then should wait someone else if met and simply it.. :-(


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/9820/1047776875@github.com>

lacygoill

unread,
Feb 22, 2022, 10:02:21 AM2/22/22
to vim/vim, Subscribed

You need to find a minimal working example. If the issue depends on a plugin, you don't need pathogen. The latter simply updates the runtimepath. Just write:

set runtimepath^=/path/to/my/plugin

If the plugin also contains an after/ subdirectory, add this line:

set runtimepath+=/path/to/my/plugin/after

Here is another tip which might help: create the /tmp/home/.vim directory, and start Vim like this:

HOME=/tmp/home/ vim

Copy your config under /tmp/home/.vim/, and remove as many files as you can from there. Also, remove as much code as possible in the copied vimrc (/tmp/home/.vim/vimrc or /tmp/home/.vimrc).


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/9820/1047885895@github.com>

Yegappan Lakshmanan

unread,
Feb 22, 2022, 10:10:20 AM2/22/22
to vim_dev, reply+ACY5DGGRJWR7GTGMXP...@reply.github.com, vim/vim, Subscribed
Hi,

On Tue, Feb 22, 2022 at 5:06 AM Shane-XB-Qian <vim-dev...@256bit.org> wrote:

that func should be in a autoload fs, then in plugin registers a init call foo#watch() to call that func:

function! foo#watch() abort
  let s:timer = timer_start(0, function('s:watch_callback'))
endfunction


Where is the s:watch_callback() function defined? Is it in the plugin file or in the
autoload file? If it is defined in the autoload file, then you cannot use it from the
plugin file (as it is script local to the autoload file).

- Yegappan

vim-dev ML

unread,
Feb 22, 2022, 10:10:38 AM2/22/22
to vim/vim, vim-dev ML, Your activity

Hi,

On Tue, Feb 22, 2022 at 5:06 AM Shane-XB-Qian ***@***.***>

wrote:

> that func should be in a autoload fs, then in plugin registers a init
> call foo#watch() to call that func:
>
> function! foo#watch() abort
> let s:timer = timer_start(0, function('s:watch_callback'))endfunction

>
>
Where is the s:watch_callback() function defined? Is it in the plugin file
or in the
autoload file? If it is defined in the autoload file, then you cannot use
it from the
plugin file (as it is script local to the autoload file).

- Yegappan


> perhaps can be using tpop's pathogen to test that.
> // but yea, i am not sure if that's a minimal case which to be reproduce,
> or then should wait someone else if met and simply it.. :-(
>
>
>


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/9820/1047894603@github.com>

Shane-XB-Qian

unread,
Feb 22, 2022, 10:47:44 AM2/22/22
to vim/vim, vim-dev ML, Comment

> Where is the s:watch_callback() function defined?

1, `s:watch_callback()` and `foo#watch()` both defined in autoload/foo.vim
2, then `call foo#watch()` in `plugin/foo.vim`


and i just do a bisect, looks patch v8.2.4429 is the cause.
// no err if with v8.2.4428

and more weird is looks it happened if vim just startup with a fs which its ft is your lsp supported (and lsp#lsp#AddServer(cfg) registerred) -_-#


--
shane.xb.qian


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 commented.Message ID: <vim/vim/issues/9820/1047932531@github.com>

Bram Moolenaar

unread,
Feb 22, 2022, 12:48:36 PM2/22/22
to vim/vim, vim-dev ML, Comment

Hmm, maybe the bug that 8.2.4429 fixed uncovered a problem in the plugin?
Previously when using s:Function in a callback, it could call s:Function in another script. when the callback is executed.
While the intention is that s:Function is used from the script where the callback is created.
In other words: was the plugin relying on the bug that was fixed?


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 commented.Message ID: <vim/vim/issues/9820/1048056018@github.com>

Shane-XB-Qian

unread,
Feb 23, 2022, 8:22:47 AM2/23/22
to vim/vim, vim-dev ML, Comment

once i changed foo#watch() to this:

function! foo#watch() abort
  let s:timer = timer_start(1000, function('s:watch_callback'))
endfunction

Note: from 0 to 1000, seems issue is gone! -_-#
// not sure why, but looks there was vim9/legacy script compile timing conflict?!


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 commented.Message ID: <vim/vim/issues/9820/1048776578@github.com>

Shane-XB-Qian

unread,
Feb 24, 2022, 10:39:52 PM2/24/22
to vim/vim, vim-dev ML, Comment

in vim-go: @bhcleek

vim-go/autoload/go/lsp.vim|1332| <SNR>245_debug[5]
|| E700: Unknown function: s:debugasync
vim-go/autoload/go/lsp.vim|136| 298[3]
|| E714: List required

in siginify:

vim-signify/autoload/sy/repo.vim|102| sy#repo#get_diff[29]
|| E700: Unknown function: s:callback_vim_close

though err happened at extra plugins and those are legacy vim script, but i think those all caused by recently vim9 s: change.


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 commented.Message ID: <vim/vim/issues/9820/1050491577@github.com>

Billie Cleek

unread,
Feb 24, 2022, 11:40:13 PM2/24/22
to vim/vim, vim-dev ML, Comment

I can't duplicate that error with 8.2.4450. If there's something about vim-go that you think needs to change, please open a proper bug report there.


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 commented.Message ID: <vim/vim/issues/9820/1050515624@github.com>

Shane-XB-Qian

unread,
Feb 25, 2022, 1:42:25 AM2/25/22
to vim/vim, vim-dev ML, Comment

yea, once i delayed the lsp startup after vimenter, then everything looks ok.
// seems a compile timing conflict... FYI. anyway.


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 commented.Message ID: <vim/vim/issues/9820/1050571318@github.com>

Bram Moolenaar

unread,
Mar 11, 2022, 1:54:46 PM3/11/22
to vim/vim, vim-dev ML, Comment

Closed #9820 via fb43cfc.


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 commented.Message ID: <vim/vim/issue/9820/issue_event/6226895665@github.com>

Shane-XB-Qian

unread,
Mar 11, 2022, 4:09:16 PM3/11/22
to vim/vim, vim-dev ML, Comment

seems finally fixed after long searching...
thanks everyone!! and saving others people's time in advance.. :-)


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 commented.Message ID: <vim/vim/issues/9820/1065524770@github.com>

Reply all
Reply to author
Forward
0 new messages