Trouble with autoloaded self functions in dict

63 views
Skip to first unread message

Björn Linse

unread,
Aug 5, 2017, 4:16:48 AM8/5/17
to vim_dev

Place the following in the autoload path:

function dictautotest#doit() dict
endfunction

And the following in a separate test script:

let mydict = { 'doit': function('dictautotest#doit') }
let Mypartial = mydict.doit
call Mypartial()

This script will fail first time it is run. The reason is at partial construction time, the function will not be autoloaded, and treated by default as a non-dict function, and thus the partial will not store the self dict. However at call time the function is loaded, and suddenly treated as a dict function, and now vim complains that the function is called without Dictionary, because the partial lacks the self attribute.

Either the partial construction code should probably autoload the function, or somehow construct it as a "maybe-self" partial, that silently will discard the self if it turned out not to be a dict function.

Reply all
Reply to author
Forward
0 new messages