Vim9: Not able to invoke one exported function from another

15 views
Skip to first unread message

Yegappan Lakshmanan

unread,
Jan 10, 2022, 9:48:53 PM1/10/22
to vim_dev
Hi,

Using the latest Vim, when I source the following script:

---------------------------------------------------------------------------------------------
vim9script

mkdir('Xtest/autoload', 'p')

var lines =<< trim END
vim9script
import "./a.vim"
def Xtest#Test(): string
return a.F1()
enddef
END
writefile(lines, 'Xtest/autoload/Xtest.vim')

lines =<< trim END
vim9script
export def F2(): string
return "Hello"
enddef
export def F1(): string
return F2()
enddef
END
writefile(lines, 'Xtest/autoload/a.vim')

set rtp+=./Xtest
echo Xtest#Test()

delete('Xtest', 'rf')
---------------------------------------------------------------------------------------------

I get the "E117: Unknown function: F2" error message (even though the function
is present). If I remove "export" from the F2() function definition,
then the error
goes away.

- Yegappan

Bram Moolenaar

unread,
Jan 11, 2022, 10:26:22 AM1/11/22
to vim...@googlegroups.com, Yegappan Lakshmanan
The function is stored with the autoload name "a#F2" but the code that
looks up the function didn't use the "a#" prefix. I'll fix that.

--
The greatest lies of all time:
(1) The check is in the mail.
(2) We have a really challenging assignment for you.
(3) I love you.
(4) All bugs have been fixed.
(5) This won't hurt a bit.
(6) Honey, I just need to debug this program and be home in 5 minutes.
(7) I have just sent you an e-mail about that.
(8) Of course I'll respect you in the morning.
(9) I'm from the government, and I'm here to help you.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages