Mercurial > vim
comparison src/vim9expr.c @ 27086:1e2a6c6c7e42 v8.2.4072
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Commit: https://github.com/vim/vim/commit/d041f4208b0a2149e9d41f6443aa1c14c076a411
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jan 12 19:54:00 2022 +0000
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Problem: Vim9: compiling function fails when autoload script is not loaded
yet.
Solution: Depend on runtime loading.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 12 Jan 2022 21:00:05 +0100 |
parents | 15f40772e10a |
children | 98a01021e465 |
comparison
equal
deleted
inserted
replaced
27085:40b273e28f26 | 27086:1e2a6c6c7e42 |
---|---|
272 char_u *p = skipwhite(*end); | 272 char_u *p = skipwhite(*end); |
273 char_u *exp_name; | 273 char_u *exp_name; |
274 int cc; | 274 int cc; |
275 ufunc_T *ufunc; | 275 ufunc_T *ufunc; |
276 type_T *type; | 276 type_T *type; |
277 int done = FALSE; | |
278 int res = OK; | |
277 | 279 |
278 // TODO: if this is an autoload import do something else. | 280 // TODO: if this is an autoload import do something else. |
279 // Need to lookup the member. | 281 // Need to lookup the member. |
280 if (*p != '.') | 282 if (*p != '.') |
281 { | 283 { |
294 while (eval_isnamec(*p)) | 296 while (eval_isnamec(*p)) |
295 ++p; | 297 ++p; |
296 cc = *p; | 298 cc = *p; |
297 *p = NUL; | 299 *p = NUL; |
298 | 300 |
299 idx = find_exported(import->imp_sid, exp_name, &ufunc, &type, | 301 si = SCRIPT_ITEM(import->imp_sid); |
302 if (si->sn_autoload_prefix != NULL | |
303 && si->sn_state == SN_STATE_NOT_LOADED) | |
304 { | |
305 char_u *auto_name = concat_str(si->sn_autoload_prefix, exp_name); | |
306 | |
307 // autoload script must be loaded later, access by the autoload | |
308 // name. | |
309 if (cc == '(') | |
310 res = generate_PUSHFUNC(cctx, auto_name, &t_func_any); | |
311 else | |
312 res = generate_LOAD(cctx, ISN_LOADG, 0, auto_name, &t_any); | |
313 vim_free(auto_name); | |
314 done = TRUE; | |
315 } | |
316 else | |
317 { | |
318 idx = find_exported(import->imp_sid, exp_name, &ufunc, &type, | |
300 cctx, TRUE); | 319 cctx, TRUE); |
320 } | |
301 *p = cc; | 321 *p = cc; |
302 p = skipwhite(p); | 322 p = skipwhite(p); |
303 *end = p; | 323 *end = p; |
324 if (done) | |
325 return res; | |
304 | 326 |
305 if (idx < 0) | 327 if (idx < 0) |
306 { | 328 { |
307 if (ufunc != NULL) | 329 if (ufunc != NULL) |
308 { | 330 { |