blob: faee1316c4dc368867e32c691f6969b94da9af57 [file] [log] [blame]
Bram Moolenaar8a7d6542020-01-26 15:56:19 +01001/* vi:set ts=8 sts=4 sw=4 noet:
2 *
3 * VIM - Vi IMproved by Bram Moolenaar
4 *
5 * Do ":help uganda" in Vim to read copying and usage conditions.
6 * Do ":help credits" in Vim to see a list of people who contributed.
7 * See README.txt for an overview of the Vim source code.
8 */
9
10/*
11 * vim9script.c: :vim9script, :import, :export and friends
12 */
13
14#include "vim.h"
15
Bram Moolenaar9b8d6222020-12-28 18:26:00 +010016#if defined(FEAT_EVAL)
17# include "vim9.h"
18#endif
Bram Moolenaar8a7d6542020-01-26 15:56:19 +010019
Bram Moolenaar8a7d6542020-01-26 15:56:19 +010020 int
21in_vim9script(void)
22{
Bram Moolenaareb6880b2020-07-12 17:07:05 +020023 // Do not go up the stack, a ":function" inside vim9script uses legacy
24 // syntax. "sc_version" is also set when compiling a ":def" function in
25 // legacy script.
Bram Moolenaar9979fcd2021-02-14 13:30:01 +010026 return current_sctx.sc_version == SCRIPT_VERSION_VIM9
27 || (cmdmod.cmod_flags & CMOD_VIM9CMD);
Bram Moolenaar8a7d6542020-01-26 15:56:19 +010028}
29
30/*
31 * ":vim9script".
32 */
33 void
Bram Moolenaar9b8d6222020-12-28 18:26:00 +010034ex_vim9script(exarg_T *eap UNUSED)
Bram Moolenaar8a7d6542020-01-26 15:56:19 +010035{
Bram Moolenaar9b8d6222020-12-28 18:26:00 +010036#ifdef FEAT_EVAL
Bram Moolenaar2b327002020-12-26 15:39:31 +010037 int sid = current_sctx.sc_sid;
Bram Moolenaar101f4812020-06-16 23:18:51 +020038 scriptitem_T *si;
Bram Moolenaar8a7d6542020-01-26 15:56:19 +010039
40 if (!getline_equal(eap->getline, eap->cookie, getsourceline))
41 {
Bram Moolenaar451c2e32020-08-15 16:33:28 +020042 emsg(_(e_vim9script_can_only_be_used_in_script));
Bram Moolenaar8a7d6542020-01-26 15:56:19 +010043 return;
44 }
Bram Moolenaar2b327002020-12-26 15:39:31 +010045
46 si = SCRIPT_ITEM(sid);
47 if (si->sn_state == SN_STATE_HAD_COMMAND)
Bram Moolenaar8a7d6542020-01-26 15:56:19 +010048 {
Bram Moolenaar451c2e32020-08-15 16:33:28 +020049 emsg(_(e_vim9script_must_be_first_command_in_script));
Bram Moolenaar8a7d6542020-01-26 15:56:19 +010050 return;
51 }
Bram Moolenaar2b327002020-12-26 15:39:31 +010052 if (!IS_WHITE_OR_NUL(*eap->arg) && STRCMP(eap->arg, "noclear") != 0)
53 {
54 semsg(_(e_invarg2), eap->arg);
55 return;
56 }
57 if (si->sn_state == SN_STATE_RELOAD && IS_WHITE_OR_NUL(*eap->arg))
58 {
59 hashtab_T *ht = &SCRIPT_VARS(sid);
60
61 // Reloading a script without the "noclear" argument: clear
62 // script-local variables and functions.
63 hashtab_free_contents(ht);
64 hash_init(ht);
65 delete_script_functions(sid);
66
67 // old imports and script variables are no longer valid
68 free_imports_and_script_vars(sid);
69 }
70 si->sn_state = SN_STATE_HAD_COMMAND;
71
Bram Moolenaar8a7d6542020-01-26 15:56:19 +010072 current_sctx.sc_version = SCRIPT_VERSION_VIM9;
73 si->sn_version = SCRIPT_VERSION_VIM9;
Bram Moolenaar8a7d6542020-01-26 15:56:19 +010074
75 if (STRCMP(p_cpo, CPO_VIM) != 0)
76 {
Bram Moolenaar39ca4122020-10-20 14:25:07 +020077 si->sn_save_cpo = vim_strsave(p_cpo);
Bram Moolenaar37294bd2021-03-10 13:40:08 +010078 set_option_value((char_u *)"cpo", 0L, (char_u *)CPO_VIM, OPT_NO_REDRAW);
Bram Moolenaar8a7d6542020-01-26 15:56:19 +010079 }
Bram Moolenaar9b8d6222020-12-28 18:26:00 +010080#else
81 // No check for this being the first command, it doesn't matter.
82 current_sctx.sc_version = SCRIPT_VERSION_VIM9;
83#endif
Bram Moolenaar8a7d6542020-01-26 15:56:19 +010084}
85
86/*
Bram Moolenaarae616492020-07-28 20:07:27 +020087 * When in Vim9 script give an error and return FAIL.
88 */
89 int
90not_in_vim9(exarg_T *eap)
91{
Bram Moolenaar68e30442020-07-28 21:15:07 +020092 if (in_vim9script())
93 switch (eap->cmdidx)
94 {
Bram Moolenaarada1d872021-02-20 08:16:51 +010095 case CMD_k:
96 if (eap->addr_count > 0)
97 {
98 emsg(_(e_norange));
99 return FAIL;
100 }
101 // FALLTHROUGH
Bram Moolenaar68e30442020-07-28 21:15:07 +0200102 case CMD_append:
103 case CMD_change:
Bram Moolenaarf5a48012020-08-01 17:00:03 +0200104 case CMD_insert:
105 case CMD_t:
Bram Moolenaar68e30442020-07-28 21:15:07 +0200106 case CMD_xit:
Bram Moolenaar9b8d6222020-12-28 18:26:00 +0100107 semsg(_(e_command_not_supported_in_vim9_script_missing_var_str), eap->cmd);
Bram Moolenaar68e30442020-07-28 21:15:07 +0200108 return FAIL;
109 default: break;
110 }
Bram Moolenaarae616492020-07-28 20:07:27 +0200111 return OK;
112}
113
Bram Moolenaardcc58e02020-12-28 20:53:21 +0100114/*
115 * Return TRUE if "p" points at a "#". Does not check for white space.
116 */
117 int
118vim9_comment_start(char_u *p)
119{
120 return p[0] == '#';
121}
122
Bram Moolenaar9b8d6222020-12-28 18:26:00 +0100123#if defined(FEAT_EVAL) || defined(PROTO)
124
Bram Moolenaarae616492020-07-28 20:07:27 +0200125/*
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100126 * ":export let Name: type"
127 * ":export const Name: type"
128 * ":export def Name(..."
129 * ":export class Name ..."
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100130 */
131 void
Bram Moolenaar09689a02020-05-09 22:50:08 +0200132ex_export(exarg_T *eap)
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100133{
Bram Moolenaareb6880b2020-07-12 17:07:05 +0200134 if (!in_vim9script())
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100135 {
Bram Moolenaar451c2e32020-08-15 16:33:28 +0200136 emsg(_(e_export_can_only_be_used_in_vim9script));
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100137 return;
138 }
139
140 eap->cmd = eap->arg;
Bram Moolenaar2e2d7582021-03-03 21:22:41 +0100141 (void)find_ex_command(eap, NULL, lookup_scriptitem, NULL);
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100142 switch (eap->cmdidx)
143 {
144 case CMD_let:
Bram Moolenaar30fd8202020-09-26 15:09:30 +0200145 case CMD_var:
146 case CMD_final:
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100147 case CMD_const:
148 case CMD_def:
149 // case CMD_class:
150 is_export = TRUE;
151 do_cmdline(eap->cmd, eap->getline, eap->cookie,
152 DOCMD_VERBOSE + DOCMD_NOWAIT);
153
154 // The command will reset "is_export" when exporting an item.
155 if (is_export)
156 {
Bram Moolenaar451c2e32020-08-15 16:33:28 +0200157 emsg(_(e_export_with_invalid_argument));
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100158 is_export = FALSE;
159 }
160 break;
161 default:
Bram Moolenaar451c2e32020-08-15 16:33:28 +0200162 emsg(_(e_invalid_command_after_export));
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100163 break;
164 }
165}
166
167/*
168 * Add a new imported item entry to the current script.
169 */
170 static imported_T *
171new_imported(garray_T *gap)
172{
173 if (ga_grow(gap, 1) == OK)
174 return ((imported_T *)gap->ga_data + gap->ga_len++);
175 return NULL;
176}
177
178/*
179 * Free all imported items in script "sid".
180 */
181 void
Bram Moolenaar8d739de2020-10-14 19:39:19 +0200182free_imports_and_script_vars(int sid)
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100183{
Bram Moolenaar21b9e972020-01-26 19:26:46 +0100184 scriptitem_T *si = SCRIPT_ITEM(sid);
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100185 int idx;
186
187 for (idx = 0; idx < si->sn_imports.ga_len; ++idx)
188 {
Bram Moolenaar20431c92020-03-20 18:39:46 +0100189 imported_T *imp = ((imported_T *)si->sn_imports.ga_data) + idx;
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100190
191 vim_free(imp->imp_name);
192 }
193 ga_clear(&si->sn_imports);
Bram Moolenaar8d739de2020-10-14 19:39:19 +0200194
195 free_all_script_vars(si);
196
Bram Moolenaar6110e792020-07-08 19:35:21 +0200197 clear_type_list(&si->sn_type_list);
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100198}
199
200/*
Bram Moolenaara6294952020-12-27 13:39:50 +0100201 * Mark all imports as possible to redefine. Used when a script is loaded
202 * again but not cleared.
203 */
204 void
205mark_imports_for_reload(int sid)
206{
207 scriptitem_T *si = SCRIPT_ITEM(sid);
208 int idx;
209
210 for (idx = 0; idx < si->sn_imports.ga_len; ++idx)
211 {
212 imported_T *imp = ((imported_T *)si->sn_imports.ga_data) + idx;
213
214 imp->imp_flags |= IMP_FLAGS_RELOAD;
215 }
216}
217
218/*
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100219 * ":import Item from 'filename'"
220 * ":import Item as Alias from 'filename'"
221 * ":import {Item} from 'filename'".
222 * ":import {Item as Alias} from 'filename'"
223 * ":import {Item, Item} from 'filename'"
224 * ":import {Item, Item as Alias} from 'filename'"
225 *
226 * ":import * as Name from 'filename'"
227 */
228 void
229ex_import(exarg_T *eap)
230{
Bram Moolenaar1c991142020-07-04 13:15:31 +0200231 char_u *cmd_end;
232 evalarg_T evalarg;
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100233
Bram Moolenaar101f4812020-06-16 23:18:51 +0200234 if (!getline_equal(eap->getline, eap->cookie, getsourceline))
235 {
Bram Moolenaar451c2e32020-08-15 16:33:28 +0200236 emsg(_(e_import_can_only_be_used_in_script));
Bram Moolenaar101f4812020-06-16 23:18:51 +0200237 return;
238 }
Bram Moolenaar1c991142020-07-04 13:15:31 +0200239 fill_evalarg_from_eap(&evalarg, eap, eap->skip);
Bram Moolenaar101f4812020-06-16 23:18:51 +0200240
Bram Moolenaar1c991142020-07-04 13:15:31 +0200241 cmd_end = handle_import(eap->arg, NULL, current_sctx.sc_sid,
242 &evalarg, NULL);
Bram Moolenaar9721fb42020-06-11 23:10:46 +0200243 if (cmd_end != NULL)
244 eap->nextcmd = check_nextcmd(cmd_end);
Bram Moolenaar1c991142020-07-04 13:15:31 +0200245 clear_evalarg(&evalarg, eap);
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100246}
247
248/*
Bram Moolenaarf2d5c242020-02-23 21:25:54 +0100249 * Find an exported item in "sid" matching the name at "*argp".
250 * When it is a variable return the index.
251 * When it is a user function return "*ufunc".
252 * When not found returns -1 and "*ufunc" is NULL.
253 */
254 int
255find_exported(
256 int sid,
Bram Moolenaar1c991142020-07-04 13:15:31 +0200257 char_u *name,
Bram Moolenaarf2d5c242020-02-23 21:25:54 +0100258 ufunc_T **ufunc,
Bram Moolenaarfbbcd002020-10-15 12:46:44 +0200259 type_T **type,
Bram Moolenaarcb4e80f2021-03-13 20:57:19 +0100260 cctx_T *cctx,
261 int verbose)
Bram Moolenaarf2d5c242020-02-23 21:25:54 +0100262{
Bram Moolenaarf2d5c242020-02-23 21:25:54 +0100263 int idx = -1;
264 svar_T *sv;
265 scriptitem_T *script = SCRIPT_ITEM(sid);
266
Bram Moolenaarf2d5c242020-02-23 21:25:54 +0100267 // find name in "script"
268 // TODO: also find script-local user function
Bram Moolenaar08251752021-01-11 21:20:18 +0100269 idx = get_script_item_idx(sid, name, 0, cctx);
Bram Moolenaarf2d5c242020-02-23 21:25:54 +0100270 if (idx >= 0)
271 {
272 sv = ((svar_T *)script->sn_var_vals.ga_data) + idx;
273 if (!sv->sv_export)
274 {
Bram Moolenaarcb4e80f2021-03-13 20:57:19 +0100275 if (verbose)
276 semsg(_(e_item_not_exported_in_script_str), name);
Bram Moolenaarf2d5c242020-02-23 21:25:54 +0100277 return -1;
278 }
279 *type = sv->sv_type;
280 *ufunc = NULL;
281 }
282 else
283 {
284 char_u buffer[200];
285 char_u *funcname;
286
287 // it could be a user function.
Bram Moolenaar5a67c372020-07-23 14:39:47 +0200288 if (STRLEN(name) < sizeof(buffer) - 15)
Bram Moolenaarf2d5c242020-02-23 21:25:54 +0100289 funcname = buffer;
290 else
291 {
Bram Moolenaar5a67c372020-07-23 14:39:47 +0200292 funcname = alloc(STRLEN(name) + 15);
Bram Moolenaarf2d5c242020-02-23 21:25:54 +0100293 if (funcname == NULL)
Bram Moolenaarf2d5c242020-02-23 21:25:54 +0100294 return -1;
Bram Moolenaarf2d5c242020-02-23 21:25:54 +0100295 }
296 funcname[0] = K_SPECIAL;
297 funcname[1] = KS_EXTRA;
298 funcname[2] = (int)KE_SNR;
299 sprintf((char *)funcname + 3, "%ld_%s", (long)sid, name);
Bram Moolenaar4c17ad92020-04-27 22:47:51 +0200300 *ufunc = find_func(funcname, FALSE, NULL);
Bram Moolenaarf2d5c242020-02-23 21:25:54 +0100301 if (funcname != buffer)
302 vim_free(funcname);
303
304 if (*ufunc == NULL)
305 {
Bram Moolenaarcb4e80f2021-03-13 20:57:19 +0100306 if (verbose)
307 semsg(_(e_item_not_found_in_script_str), name);
Bram Moolenaarf2d5c242020-02-23 21:25:54 +0100308 return -1;
309 }
310 }
Bram Moolenaarf2d5c242020-02-23 21:25:54 +0100311
312 return idx;
313}
314
315/*
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100316 * Handle an ":import" command and add the resulting imported_T to "gap", when
317 * not NULL, or script "import_sid" sn_imports.
Bram Moolenaarfbbcd002020-10-15 12:46:44 +0200318 * "cctx" is NULL at the script level.
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100319 * Returns a pointer to after the command or NULL in case of failure
320 */
321 char_u *
Bram Moolenaar1c991142020-07-04 13:15:31 +0200322handle_import(
323 char_u *arg_start,
324 garray_T *gap,
325 int import_sid,
326 evalarg_T *evalarg,
327 void *cctx)
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100328{
329 char_u *arg = arg_start;
Bram Moolenaar1c991142020-07-04 13:15:31 +0200330 char_u *cmd_end = NULL;
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100331 int ret = FAIL;
332 typval_T tv;
333 int sid = -1;
334 int res;
Bram Moolenaar0a842842021-02-27 22:41:19 +0100335 int mult = FALSE;
Bram Moolenaar1c991142020-07-04 13:15:31 +0200336 garray_T names;
Bram Moolenaar0a842842021-02-27 22:41:19 +0100337 garray_T as_names;
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100338
Bram Moolenaar1c991142020-07-04 13:15:31 +0200339 ga_init2(&names, sizeof(char_u *), 10);
Bram Moolenaar0a842842021-02-27 22:41:19 +0100340 ga_init2(&as_names, sizeof(char_u *), 10);
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100341 if (*arg == '{')
342 {
Bram Moolenaar1c991142020-07-04 13:15:31 +0200343 // "import {item, item} from ..."
Bram Moolenaar0a842842021-02-27 22:41:19 +0100344 mult = TRUE;
Bram Moolenaar1c991142020-07-04 13:15:31 +0200345 arg = skipwhite_and_linebreak(arg + 1, evalarg);
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100346 }
Bram Moolenaar1c991142020-07-04 13:15:31 +0200347
Bram Moolenaar0a842842021-02-27 22:41:19 +0100348 for (;;)
349 {
350 char_u *p = arg;
351 int had_comma = FALSE;
352 char_u *as_name = NULL;
353
354 // accept "*" or "Name"
355 if (!mult && arg[0] == '*' && IS_WHITE_OR_NUL(arg[1]))
356 ++arg;
357 else
Bram Moolenaarfa29c8a2020-02-23 22:35:05 +0100358 while (eval_isnamec(*arg))
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100359 ++arg;
Bram Moolenaar0a842842021-02-27 22:41:19 +0100360 if (p == arg)
361 break;
362 if (ga_grow(&names, 1) == FAIL || ga_grow(&as_names, 1) == FAIL)
Bram Moolenaar1c991142020-07-04 13:15:31 +0200363 goto erret;
Bram Moolenaar0a842842021-02-27 22:41:19 +0100364 ((char_u **)names.ga_data)[names.ga_len] = vim_strnsave(p, arg - p);
365 ++names.ga_len;
Bram Moolenaar1c991142020-07-04 13:15:31 +0200366
Bram Moolenaar0a842842021-02-27 22:41:19 +0100367 arg = skipwhite_and_linebreak(arg, evalarg);
Bram Moolenaar1c991142020-07-04 13:15:31 +0200368 if (STRNCMP("as", arg, 2) == 0 && IS_WHITE_OR_NUL(arg[2]))
369 {
Bram Moolenaar1c991142020-07-04 13:15:31 +0200370 // skip over "as Name "; no line break allowed after "as"
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100371 arg = skipwhite(arg + 2);
Bram Moolenaar1c991142020-07-04 13:15:31 +0200372 p = arg;
Bram Moolenaarfa29c8a2020-02-23 22:35:05 +0100373 if (eval_isnamec1(*arg))
374 while (eval_isnamec(*arg))
375 ++arg;
Bram Moolenaar057e84a2021-02-28 16:55:11 +0100376 if (check_defined(p, arg - p, cctx, FALSE) == FAIL)
Bram Moolenaar1c991142020-07-04 13:15:31 +0200377 goto erret;
378 as_name = vim_strnsave(p, arg - p);
379 arg = skipwhite_and_linebreak(arg, evalarg);
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100380 }
381 else if (*arg_start == '*')
382 {
Bram Moolenaar451c2e32020-08-15 16:33:28 +0200383 emsg(_(e_missing_as_after_star));
Bram Moolenaar1c991142020-07-04 13:15:31 +0200384 goto erret;
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100385 }
Bram Moolenaar0a842842021-02-27 22:41:19 +0100386 // without "as Name" the as_names entry is NULL
387 ((char_u **)as_names.ga_data)[as_names.ga_len] = as_name;
388 ++as_names.ga_len;
389
390 if (!mult)
391 break;
392 if (*arg == ',')
393 {
394 had_comma = TRUE;
395 ++arg;
396 }
397 arg = skipwhite_and_linebreak(arg, evalarg);
398 if (*arg == '}')
399 {
400 ++arg;
401 break;
402 }
403 if (!had_comma)
404 {
405 emsg(_(e_missing_comma_in_import));
406 goto erret;
407 }
408 }
409 arg = skipwhite_and_linebreak(arg, evalarg);
410
411 if (names.ga_len == 0)
412 {
413 emsg(_(e_syntax_error_in_import));
414 goto erret;
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100415 }
Bram Moolenaar1c991142020-07-04 13:15:31 +0200416
417 if (STRNCMP("from", arg, 4) != 0 || !IS_WHITE_OR_NUL(arg[4]))
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100418 {
Bram Moolenaar451c2e32020-08-15 16:33:28 +0200419 emsg(_(e_missing_from));
Bram Moolenaar1c991142020-07-04 13:15:31 +0200420 goto erret;
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100421 }
Bram Moolenaar1c991142020-07-04 13:15:31 +0200422
Bram Moolenaar962d7212020-07-04 14:15:00 +0200423 arg = skipwhite_and_linebreak(arg + 4, evalarg);
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100424 tv.v_type = VAR_UNKNOWN;
425 // TODO: should we accept any expression?
426 if (*arg == '\'')
Bram Moolenaar9a78e6d2020-07-01 18:29:55 +0200427 ret = eval_lit_string(&arg, &tv, TRUE);
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100428 else if (*arg == '"')
Bram Moolenaar9a78e6d2020-07-01 18:29:55 +0200429 ret = eval_string(&arg, &tv, TRUE);
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100430 if (ret == FAIL || tv.vval.v_string == NULL || *tv.vval.v_string == NUL)
431 {
Bram Moolenaar451c2e32020-08-15 16:33:28 +0200432 emsg(_(e_invalid_string_after_from));
Bram Moolenaar1c991142020-07-04 13:15:31 +0200433 goto erret;
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100434 }
435 cmd_end = arg;
436
Bram Moolenaar1c991142020-07-04 13:15:31 +0200437 /*
438 * find script file
439 */
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100440 if (*tv.vval.v_string == '.')
441 {
442 size_t len;
Bram Moolenaar21b9e972020-01-26 19:26:46 +0100443 scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100444 char_u *tail = gettail(si->sn_name);
445 char_u *from_name;
446
447 // Relative to current script: "./name.vim", "../../name.vim".
448 len = STRLEN(si->sn_name) - STRLEN(tail) + STRLEN(tv.vval.v_string) + 2;
449 from_name = alloc((int)len);
450 if (from_name == NULL)
451 {
452 clear_tv(&tv);
Bram Moolenaar1c991142020-07-04 13:15:31 +0200453 goto erret;
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100454 }
455 vim_strncpy(from_name, si->sn_name, tail - si->sn_name);
456 add_pathsep(from_name);
457 STRCAT(from_name, tv.vval.v_string);
458 simplify_filename(from_name);
459
460 res = do_source(from_name, FALSE, DOSO_NONE, &sid);
461 vim_free(from_name);
462 }
463 else if (mch_isFullName(tv.vval.v_string))
464 {
465 // Absolute path: "/tmp/name.vim"
466 res = do_source(tv.vval.v_string, FALSE, DOSO_NONE, &sid);
467 }
468 else
469 {
470 size_t len = 7 + STRLEN(tv.vval.v_string) + 1;
471 char_u *from_name;
472
473 // Find file in "import" subdirs in 'runtimepath'.
474 from_name = alloc((int)len);
475 if (from_name == NULL)
476 {
477 clear_tv(&tv);
Bram Moolenaar1c991142020-07-04 13:15:31 +0200478 goto erret;
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100479 }
480 vim_snprintf((char *)from_name, len, "import/%s", tv.vval.v_string);
481 res = source_in_path(p_rtp, from_name, DIP_NOAFTER, &sid);
482 vim_free(from_name);
483 }
484
485 if (res == FAIL || sid <= 0)
486 {
Bram Moolenaar451c2e32020-08-15 16:33:28 +0200487 semsg(_(e_could_not_import_str), tv.vval.v_string);
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100488 clear_tv(&tv);
Bram Moolenaar1c991142020-07-04 13:15:31 +0200489 goto erret;
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100490 }
491 clear_tv(&tv);
492
493 if (*arg_start == '*')
494 {
Bram Moolenaar0a842842021-02-27 22:41:19 +0100495 imported_T *imported;
496 char_u *as_name = ((char_u **)as_names.ga_data)[0];
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100497
Bram Moolenaar0a842842021-02-27 22:41:19 +0100498 // "import * as That"
Bram Moolenaara6294952020-12-27 13:39:50 +0100499 imported = find_imported(as_name, STRLEN(as_name), cctx);
500 if (imported != NULL && imported->imp_sid == sid)
501 {
502 if (imported->imp_flags & IMP_FLAGS_RELOAD)
503 // import already defined on a previous script load
504 imported->imp_flags &= ~IMP_FLAGS_RELOAD;
505 else
506 {
507 semsg(_(e_name_already_defined_str), as_name);
508 goto erret;
509 }
510 }
511
512 imported = new_imported(gap != NULL ? gap
513 : &SCRIPT_ITEM(import_sid)->sn_imports);
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100514 if (imported == NULL)
Bram Moolenaar1c991142020-07-04 13:15:31 +0200515 goto erret;
516 imported->imp_name = as_name;
Bram Moolenaar0a842842021-02-27 22:41:19 +0100517 ((char_u **)as_names.ga_data)[0] = NULL;
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100518 imported->imp_sid = sid;
Bram Moolenaara6294952020-12-27 13:39:50 +0100519 imported->imp_flags = IMP_FLAGS_STAR;
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100520 }
521 else
522 {
Bram Moolenaar1c991142020-07-04 13:15:31 +0200523 int i;
524
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100525 arg = arg_start;
526 if (*arg == '{')
527 arg = skipwhite(arg + 1);
Bram Moolenaar1c991142020-07-04 13:15:31 +0200528 for (i = 0; i < names.ga_len; ++i)
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100529 {
Bram Moolenaar1c991142020-07-04 13:15:31 +0200530 char_u *name = ((char_u **)names.ga_data)[i];
Bram Moolenaar0a842842021-02-27 22:41:19 +0100531 char_u *as_name = ((char_u **)as_names.ga_data)[i];
Bram Moolenaara6294952020-12-27 13:39:50 +0100532 size_t len = STRLEN(name);
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100533 int idx;
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100534 imported_T *imported;
Bram Moolenaarf2d5c242020-02-23 21:25:54 +0100535 ufunc_T *ufunc = NULL;
536 type_T *type;
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100537
Bram Moolenaarcb4e80f2021-03-13 20:57:19 +0100538 idx = find_exported(sid, name, &ufunc, &type, cctx, TRUE);
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100539
Bram Moolenaarf2d5c242020-02-23 21:25:54 +0100540 if (idx < 0 && ufunc == NULL)
Bram Moolenaar1c991142020-07-04 13:15:31 +0200541 goto erret;
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100542
Bram Moolenaara6294952020-12-27 13:39:50 +0100543 // If already imported with the same propertis and the
544 // IMP_FLAGS_RELOAD set then we keep that entry. Otherwise create
545 // a new one (and give an error for an existing import).
546 imported = find_imported(name, len, cctx);
547 if (imported != NULL
548 && (imported->imp_flags & IMP_FLAGS_RELOAD)
549 && imported->imp_sid == sid
550 && (idx >= 0
551 ? (equal_type(imported->imp_type, type)
552 && imported->imp_var_vals_idx == idx)
553 : (equal_type(imported->imp_type, ufunc->uf_func_type)
554 && STRCMP(imported->imp_funcname,
555 ufunc->uf_name) == 0)))
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100556 {
Bram Moolenaara6294952020-12-27 13:39:50 +0100557 imported->imp_flags &= ~IMP_FLAGS_RELOAD;
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100558 }
559 else
Bram Moolenaar40f4f7a2020-07-23 22:41:43 +0200560 {
Bram Moolenaar057e84a2021-02-28 16:55:11 +0100561 if (check_defined(name, len, cctx, FALSE) == FAIL)
Bram Moolenaara6294952020-12-27 13:39:50 +0100562 goto erret;
563
564 imported = new_imported(gap != NULL ? gap
565 : &SCRIPT_ITEM(import_sid)->sn_imports);
566 if (imported == NULL)
567 goto erret;
568
Bram Moolenaar0a842842021-02-27 22:41:19 +0100569 if (as_name == NULL)
570 {
571 imported->imp_name = name;
572 ((char_u **)names.ga_data)[i] = NULL;
Bram Moolenaar057e84a2021-02-28 16:55:11 +0100573 }
Bram Moolenaar0a842842021-02-27 22:41:19 +0100574 else
575 {
576 // "import This as That ..."
577 imported->imp_name = as_name;
578 ((char_u **)as_names.ga_data)[i] = NULL;
579 }
Bram Moolenaara6294952020-12-27 13:39:50 +0100580 imported->imp_sid = sid;
581 if (idx >= 0)
582 {
583 imported->imp_type = type;
584 imported->imp_var_vals_idx = idx;
585 }
586 else
587 {
588 imported->imp_type = ufunc->uf_func_type;
589 imported->imp_funcname = ufunc->uf_name;
590 }
Bram Moolenaar40f4f7a2020-07-23 22:41:43 +0200591 }
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100592 }
593 }
Bram Moolenaar1c991142020-07-04 13:15:31 +0200594erret:
595 ga_clear_strings(&names);
Bram Moolenaar0a842842021-02-27 22:41:19 +0100596 ga_clear_strings(&as_names);
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100597 return cmd_end;
598}
599
Bram Moolenaarc82a5b52020-06-13 18:09:19 +0200600/*
601 * Declare a script-local variable without init: "let var: type".
602 * "const" is an error since the value is missing.
603 * Returns a pointer to after the type.
604 */
605 char_u *
606vim9_declare_scriptvar(exarg_T *eap, char_u *arg)
607{
608 char_u *p;
609 char_u *name;
610 scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
611 type_T *type;
Bram Moolenaarc82a5b52020-06-13 18:09:19 +0200612 typval_T init_tv;
613
Bram Moolenaar30fd8202020-09-26 15:09:30 +0200614 if (eap->cmdidx == CMD_final || eap->cmdidx == CMD_const)
Bram Moolenaarc82a5b52020-06-13 18:09:19 +0200615 {
Bram Moolenaar30fd8202020-09-26 15:09:30 +0200616 if (eap->cmdidx == CMD_final)
617 emsg(_(e_final_requires_a_value));
618 else
619 emsg(_(e_const_requires_a_value));
Bram Moolenaarc82a5b52020-06-13 18:09:19 +0200620 return arg + STRLEN(arg);
621 }
622
623 // Check for valid starting character.
624 if (!eval_isnamec1(*arg))
625 {
626 semsg(_(e_invarg2), arg);
627 return arg + STRLEN(arg);
628 }
629
Bram Moolenaar984dddb2020-06-14 12:50:24 +0200630 for (p = arg + 1; *p != NUL && eval_isnamec(*p); MB_PTR_ADV(p))
Bram Moolenaar3b74b6b2020-06-19 19:01:43 +0200631 if (*p == ':' && (VIM_ISWHITE(p[1]) || p != arg + 1))
Bram Moolenaar984dddb2020-06-14 12:50:24 +0200632 break;
Bram Moolenaarc82a5b52020-06-13 18:09:19 +0200633
634 if (*p != ':')
635 {
Bram Moolenaarbc4c5052020-08-13 22:47:35 +0200636 emsg(_(e_type_or_initialization_required));
Bram Moolenaarc82a5b52020-06-13 18:09:19 +0200637 return arg + STRLEN(arg);
638 }
Bram Moolenaar984dddb2020-06-14 12:50:24 +0200639 if (!VIM_ISWHITE(p[1]))
640 {
Bram Moolenaarc3fc75d2021-02-07 15:28:09 +0100641 semsg(_(e_white_space_required_after_str_str), ":", p);
Bram Moolenaar984dddb2020-06-14 12:50:24 +0200642 return arg + STRLEN(arg);
643 }
Bram Moolenaarc82a5b52020-06-13 18:09:19 +0200644 name = vim_strnsave(arg, p - arg);
645
646 // parse type
647 p = skipwhite(p + 1);
Bram Moolenaar9e68c322020-12-25 12:38:04 +0100648 type = parse_type(&p, &si->sn_type_list, TRUE);
649 if (type == NULL)
Bram Moolenaarf3decc52020-06-13 19:56:38 +0200650 {
651 vim_free(name);
Bram Moolenaarc82a5b52020-06-13 18:09:19 +0200652 return p;
Bram Moolenaarf3decc52020-06-13 19:56:38 +0200653 }
Bram Moolenaarc82a5b52020-06-13 18:09:19 +0200654
655 // Create the variable with 0/NULL value.
656 CLEAR_FIELD(init_tv);
Bram Moolenaarf0afd9e2020-09-13 18:57:47 +0200657 if (type->tt_type == VAR_ANY)
658 // A variable of type "any" is not possible, just use zero instead
659 init_tv.v_type = VAR_NUMBER;
660 else
661 init_tv.v_type = type->tt_type;
Bram Moolenaarf785aa12021-02-11 21:19:34 +0100662 set_var_const(name, type, &init_tv, FALSE, 0, 0);
Bram Moolenaarc82a5b52020-06-13 18:09:19 +0200663
664 vim_free(name);
665 return p;
666}
667
Bram Moolenaar34db91f2020-06-13 19:00:10 +0200668/*
Bram Moolenaar39ca4122020-10-20 14:25:07 +0200669 * Vim9 part of adding a script variable: add it to sn_all_vars (lookup by name
670 * with a hashtable) and sn_var_vals (lookup by index).
Bram Moolenaar07a65d22020-12-26 20:09:15 +0100671 * When "create" is TRUE this is a new variable, otherwise find and update an
672 * existing variable.
Bram Moolenaar08251752021-01-11 21:20:18 +0100673 * "flags" can have ASSIGN_FINAL or ASSIGN_CONST.
Bram Moolenaaraa210a32021-01-02 15:41:03 +0100674 * When "*type" is NULL use "tv" for the type and update "*type".
Bram Moolenaar8d739de2020-10-14 19:39:19 +0200675 */
676 void
Bram Moolenaar08251752021-01-11 21:20:18 +0100677update_vim9_script_var(
678 int create,
679 dictitem_T *di,
680 int flags,
681 typval_T *tv,
682 type_T **type)
Bram Moolenaar8d739de2020-10-14 19:39:19 +0200683{
Bram Moolenaar07a65d22020-12-26 20:09:15 +0100684 scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
685 hashitem_T *hi;
686 svar_T *sv;
Bram Moolenaar8d739de2020-10-14 19:39:19 +0200687
Bram Moolenaar07a65d22020-12-26 20:09:15 +0100688 if (create)
Bram Moolenaar8d739de2020-10-14 19:39:19 +0200689 {
Bram Moolenaar07a65d22020-12-26 20:09:15 +0100690 sallvar_T *newsav;
Bram Moolenaar8d739de2020-10-14 19:39:19 +0200691
Bram Moolenaar07a65d22020-12-26 20:09:15 +0100692 // Store a pointer to the typval_T, so that it can be found by index
693 // instead of using a hastab lookup.
694 if (ga_grow(&si->sn_var_vals, 1) == FAIL)
695 return;
696
697 sv = ((svar_T *)si->sn_var_vals.ga_data) + si->sn_var_vals.ga_len;
698 newsav = (sallvar_T *)alloc_clear(
699 sizeof(sallvar_T) + STRLEN(di->di_key));
Bram Moolenaar8d739de2020-10-14 19:39:19 +0200700 if (newsav == NULL)
701 return;
702
703 sv->sv_tv = &di->di_tv;
Bram Moolenaar08251752021-01-11 21:20:18 +0100704 sv->sv_const = (flags & ASSIGN_FINAL) ? ASSIGN_FINAL
705 : (flags & ASSIGN_CONST) ? ASSIGN_CONST : 0;
Bram Moolenaar8d739de2020-10-14 19:39:19 +0200706 sv->sv_export = is_export;
707 newsav->sav_var_vals_idx = si->sn_var_vals.ga_len;
708 ++si->sn_var_vals.ga_len;
Bram Moolenaar8d739de2020-10-14 19:39:19 +0200709 STRCPY(&newsav->sav_key, di->di_key);
710 sv->sv_name = newsav->sav_key;
711 newsav->sav_di = di;
712 newsav->sav_block_id = si->sn_current_block_id;
713
714 hi = hash_find(&si->sn_all_vars.dv_hashtab, newsav->sav_key);
715 if (!HASHITEM_EMPTY(hi))
716 {
717 sallvar_T *sav = HI2SAV(hi);
718
719 // variable with this name exists in another block
720 while (sav->sav_next != NULL)
721 sav = sav->sav_next;
722 sav->sav_next = newsav;
723 }
724 else
725 // new variable name
726 hash_add(&si->sn_all_vars.dv_hashtab, newsav->sav_key);
Bram Moolenaar8d739de2020-10-14 19:39:19 +0200727 }
Bram Moolenaar07a65d22020-12-26 20:09:15 +0100728 else
729 {
730 sv = find_typval_in_script(&di->di_tv);
731 }
732 if (sv != NULL)
733 {
Bram Moolenaaraa210a32021-01-02 15:41:03 +0100734 if (*type == NULL)
735 *type = typval2type(tv, &si->sn_type_list);
736 sv->sv_type = *type;
Bram Moolenaar07a65d22020-12-26 20:09:15 +0100737 }
738
739 // let ex_export() know the export worked.
740 is_export = FALSE;
Bram Moolenaar8d739de2020-10-14 19:39:19 +0200741}
742
Bram Moolenaarfbbcd002020-10-15 12:46:44 +0200743/*
744 * Hide a script variable when leaving a block.
745 * "idx" is de index in sn_var_vals.
Bram Moolenaar39ca4122020-10-20 14:25:07 +0200746 * When "func_defined" is non-zero then a function was defined in this block,
747 * the variable may be accessed by it. Otherwise the variable can be cleared.
Bram Moolenaarfbbcd002020-10-15 12:46:44 +0200748 */
Bram Moolenaar8d739de2020-10-14 19:39:19 +0200749 void
Bram Moolenaar39ca4122020-10-20 14:25:07 +0200750hide_script_var(scriptitem_T *si, int idx, int func_defined)
Bram Moolenaar8d739de2020-10-14 19:39:19 +0200751{
Bram Moolenaarfbbcd002020-10-15 12:46:44 +0200752 svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) + idx;
Bram Moolenaar8d739de2020-10-14 19:39:19 +0200753 hashtab_T *script_ht = get_script_local_ht();
754 hashtab_T *all_ht = &si->sn_all_vars.dv_hashtab;
755 hashitem_T *script_hi;
756 hashitem_T *all_hi;
757
758 // Remove a variable declared inside the block, if it still exists.
Bram Moolenaar39ca4122020-10-20 14:25:07 +0200759 // If it was added in a nested block it will already have been removed.
Bram Moolenaar8d739de2020-10-14 19:39:19 +0200760 // The typval is moved into the sallvar_T.
761 script_hi = hash_find(script_ht, sv->sv_name);
762 all_hi = hash_find(all_ht, sv->sv_name);
763 if (!HASHITEM_EMPTY(script_hi) && !HASHITEM_EMPTY(all_hi))
764 {
765 dictitem_T *di = HI2DI(script_hi);
766 sallvar_T *sav = HI2SAV(all_hi);
Bram Moolenaar39ca4122020-10-20 14:25:07 +0200767 sallvar_T *sav_prev = NULL;
Bram Moolenaar8d739de2020-10-14 19:39:19 +0200768
Bram Moolenaarfbbcd002020-10-15 12:46:44 +0200769 // There can be multiple entries with the same name in different
770 // blocks, find the right one.
771 while (sav != NULL && sav->sav_var_vals_idx != idx)
Bram Moolenaar39ca4122020-10-20 14:25:07 +0200772 {
773 sav_prev = sav;
Bram Moolenaarfbbcd002020-10-15 12:46:44 +0200774 sav = sav->sav_next;
Bram Moolenaar39ca4122020-10-20 14:25:07 +0200775 }
Bram Moolenaarfbbcd002020-10-15 12:46:44 +0200776 if (sav != NULL)
777 {
Bram Moolenaar39ca4122020-10-20 14:25:07 +0200778 if (func_defined)
779 {
780 // move the typval from the dictitem to the sallvar
781 sav->sav_tv = di->di_tv;
782 di->di_tv.v_type = VAR_UNKNOWN;
783 sav->sav_flags = di->di_flags;
784 sav->sav_di = NULL;
785 sv->sv_tv = &sav->sav_tv;
786 }
787 else
788 {
789 if (sav_prev == NULL)
790 hash_remove(all_ht, all_hi);
791 else
792 sav_prev->sav_next = sav->sav_next;
793 sv->sv_name = NULL;
794 vim_free(sav);
795 }
Bram Moolenaarfbbcd002020-10-15 12:46:44 +0200796 delete_var(script_ht, script_hi);
Bram Moolenaarfbbcd002020-10-15 12:46:44 +0200797 }
Bram Moolenaar8d739de2020-10-14 19:39:19 +0200798 }
799}
800
801/*
802 * Free the script variables from "sn_all_vars".
803 */
804 void
805free_all_script_vars(scriptitem_T *si)
806{
807 int todo;
808 hashtab_T *ht = &si->sn_all_vars.dv_hashtab;
809 hashitem_T *hi;
810 sallvar_T *sav;
811 sallvar_T *sav_next;
812
813 hash_lock(ht);
814 todo = (int)ht->ht_used;
815 for (hi = ht->ht_array; todo > 0; ++hi)
816 {
817 if (!HASHITEM_EMPTY(hi))
818 {
819 --todo;
820
821 // Free the variable. Don't remove it from the hashtab, ht_array
822 // might change then. hash_clear() takes care of it later.
823 sav = HI2SAV(hi);
824 while (sav != NULL)
825 {
826 sav_next = sav->sav_next;
827 if (sav->sav_di == NULL)
828 clear_tv(&sav->sav_tv);
829 vim_free(sav);
830 sav = sav_next;
831 }
832 }
833 }
834 hash_clear(ht);
835 hash_init(ht);
836
837 ga_clear(&si->sn_var_vals);
Bram Moolenaar2b327002020-12-26 15:39:31 +0100838
839 // existing commands using script variable indexes are no longer valid
840 si->sn_script_seq = current_sctx.sc_seq;
Bram Moolenaar8d739de2020-10-14 19:39:19 +0200841}
842
843/*
Bram Moolenaar10c65862020-10-08 21:16:42 +0200844 * Find the script-local variable that links to "dest".
845 * Returns NULL if not found.
Bram Moolenaar34db91f2020-06-13 19:00:10 +0200846 */
Bram Moolenaar10c65862020-10-08 21:16:42 +0200847 svar_T *
848find_typval_in_script(typval_T *dest)
Bram Moolenaar34db91f2020-06-13 19:00:10 +0200849{
850 scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
851 int idx;
852
Bram Moolenaar81e17fb2020-08-21 21:55:43 +0200853 if (si->sn_version != SCRIPT_VERSION_VIM9)
854 // legacy script doesn't store variable types
Bram Moolenaar10c65862020-10-08 21:16:42 +0200855 return NULL;
Bram Moolenaar81e17fb2020-08-21 21:55:43 +0200856
Bram Moolenaar34db91f2020-06-13 19:00:10 +0200857 // Find the svar_T in sn_var_vals.
858 for (idx = 0; idx < si->sn_var_vals.ga_len; ++idx)
859 {
860 svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) + idx;
861
Bram Moolenaarc0913d02020-12-05 14:44:37 +0100862 // If "sv_name" is NULL the variable was hidden when leaving a block,
863 // don't check "sv_tv" then, it might be used for another variable now.
864 if (sv->sv_name != NULL && sv->sv_tv == dest)
Bram Moolenaar10c65862020-10-08 21:16:42 +0200865 return sv;
Bram Moolenaar34db91f2020-06-13 19:00:10 +0200866 }
Bram Moolenaarf785aa12021-02-11 21:19:34 +0100867 iemsg("find_typval_in_script(): not found");
Bram Moolenaar10c65862020-10-08 21:16:42 +0200868 return NULL;
869}
870
871/*
872 * Check if the type of script variable "dest" allows assigning "value".
873 * If needed convert "value" to a bool.
874 */
875 int
Bram Moolenaarf785aa12021-02-11 21:19:34 +0100876check_script_var_type(
877 typval_T *dest,
878 typval_T *value,
879 char_u *name,
880 where_T where)
Bram Moolenaar10c65862020-10-08 21:16:42 +0200881{
882 svar_T *sv = find_typval_in_script(dest);
883 int ret;
884
885 if (sv != NULL)
886 {
Bram Moolenaar08251752021-01-11 21:20:18 +0100887 if (sv->sv_const != 0)
Bram Moolenaar10c65862020-10-08 21:16:42 +0200888 {
889 semsg(_(e_readonlyvar), name);
890 return FAIL;
891 }
Bram Moolenaarf785aa12021-02-11 21:19:34 +0100892 ret = check_typval_type(sv->sv_type, value, where);
Bram Moolenaar10c65862020-10-08 21:16:42 +0200893 if (ret == OK && need_convert_to_bool(sv->sv_type, value))
894 {
895 int val = tv2bool(value);
896
897 clear_tv(value);
898 value->v_type = VAR_BOOL;
899 value->v_lock = 0;
900 value->vval.v_number = val ? VVAL_TRUE : VVAL_FALSE;
901 }
902 return ret;
903 }
904
Bram Moolenaarc785b9a2020-06-19 18:34:15 +0200905 return OK; // not really
Bram Moolenaar34db91f2020-06-13 19:00:10 +0200906}
Bram Moolenaarc82a5b52020-06-13 18:09:19 +0200907
Bram Moolenaar8a7d6542020-01-26 15:56:19 +0100908#endif // FEAT_EVAL