export def FastSort(): list<number>
return range(5)->sort(Compare)
enddef
+
+ export def GetString(arg: string): string
+ return arg
+ enddef
END
writefile(sortlines, 'Xsort.vim')
g:result = FastSort()
enddef
Test()
+
+ # using a function imported with "as"
+ import * as anAlias from './Xsort.vim'
+ assert_equal('yes', anAlias.GetString('yes'))
+
+ # using the function from a compiled function
+ def TestMore(): string
+ return anAlias.GetString('text')
+ enddef
+ assert_equal('text', TestMore())
+
+ # error when using a function that isn't exported
+ assert_fails('anAlias.Compare(1, 2)', 'E1049:')
END
writefile(lines, 'Xscript.vim')
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 2682,
/**/
2681,
/**/
cctx, TRUE);
*p = cc;
p = skipwhite(p);
+ *end = p;
- // TODO: what if it is a function?
if (idx < 0)
+ {
+ if (*p == '(' && ufunc != NULL)
+ {
+ generate_PUSHFUNC(cctx, ufunc->uf_name, import->imp_type);
+ return OK;
+ }
return FAIL;
- *end = p;
+ }
generate_VIM9SCRIPT(cctx, ISN_LOADSCRIPT,
import->imp_sid,
svar_T *sv;
scriptitem_T *script = SCRIPT_ITEM(sid);
- // find name in "script"
- // TODO: also find script-local user function
+ // Find name in "script".
idx = get_script_item_idx(sid, name, 0, cctx);
if (idx >= 0)
{
semsg(_(e_item_not_found_in_script_str), name);
return -1;
}
+ else if (((*ufunc)->uf_flags & FC_EXPORT) == 0)
+ {
+ if (verbose)
+ semsg(_(e_item_not_exported_in_script_str), name);
+ *ufunc = NULL;
+ return -1;
+ }
}
return idx;