Mercurial > vim
comparison src/ex_eval.c @ 20538:9f921ba86d05 v8.2.0823
patch 8.2.0823: Vim9: script reload test is disabled
Commit: https://github.com/vim/vim/commit/25e0f5863e9010a75a1ff0d04e8f886403968755
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon May 25 22:36:50 2020 +0200
patch 8.2.0823: Vim9: script reload test is disabled
Problem: Vim9: script reload test is disabled.
Solution: Compile a function in the context of the script where it was
defined. Set execution stack for compiled function. Add a test
that an error is reported for the right file/function.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 25 May 2020 22:45:03 +0200 |
parents | c225be44692a |
children | 9064044fd4f6 |
comparison
equal
deleted
inserted
replaced
20537:cceaa5ec43aa | 20538:9f921ba86d05 |
---|---|
144 cause_errthrow( | 144 cause_errthrow( |
145 char_u *mesg, | 145 char_u *mesg, |
146 int severe, | 146 int severe, |
147 int *ignore) | 147 int *ignore) |
148 { | 148 { |
149 struct msglist *elem; | 149 msglist_T *elem; |
150 struct msglist **plist; | 150 msglist_T **plist; |
151 | 151 |
152 /* | 152 /* |
153 * Do nothing when displaying the interrupt message or reporting an | 153 * Do nothing when displaying the interrupt message or reporting an |
154 * uncaught exception (which has already been discarded then) at the top | 154 * uncaught exception (which has already been discarded then) at the top |
155 * level. Also when no exception can be thrown. The message will be | 155 * level. Also when no exception can be thrown. The message will be |
249 { | 249 { |
250 plist = msg_list; | 250 plist = msg_list; |
251 while (*plist != NULL) | 251 while (*plist != NULL) |
252 plist = &(*plist)->next; | 252 plist = &(*plist)->next; |
253 | 253 |
254 elem = ALLOC_ONE(struct msglist); | 254 elem = ALLOC_CLEAR_ONE(msglist_T); |
255 if (elem == NULL) | 255 if (elem == NULL) |
256 { | 256 { |
257 suppress_errthrow = TRUE; | 257 suppress_errthrow = TRUE; |
258 emsg(_(e_outofmem)); | 258 emsg(_(e_outofmem)); |
259 } | 259 } |
285 && tmsg[9] == ' ') | 285 && tmsg[9] == ' ') |
286 (*msg_list)->throw_msg = &tmsg[4]; | 286 (*msg_list)->throw_msg = &tmsg[4]; |
287 else | 287 else |
288 (*msg_list)->throw_msg = tmsg; | 288 (*msg_list)->throw_msg = tmsg; |
289 } | 289 } |
290 | |
291 // Get the source name and lnum now, it may change before | |
292 // reaching do_errthrow(). | |
293 elem->sfile = estack_sfile(); | |
294 elem->slnum = SOURCING_LNUM; | |
290 } | 295 } |
291 } | 296 } |
292 } | 297 } |
293 return TRUE; | 298 return TRUE; |
294 } | 299 } |
296 | 301 |
297 /* | 302 /* |
298 * Free a "msg_list" and the messages it contains. | 303 * Free a "msg_list" and the messages it contains. |
299 */ | 304 */ |
300 static void | 305 static void |
301 free_msglist(struct msglist *l) | 306 free_msglist(msglist_T *l) |
302 { | 307 { |
303 struct msglist *messages, *next; | 308 msglist_T *messages, *next; |
304 | 309 |
305 messages = l; | 310 messages = l; |
306 while (messages != NULL) | 311 while (messages != NULL) |
307 { | 312 { |
308 next = messages->next; | 313 next = messages->next; |
309 vim_free(messages->msg); | 314 vim_free(messages->msg); |
315 vim_free(messages->sfile); | |
310 vim_free(messages); | 316 vim_free(messages); |
311 messages = next; | 317 messages = next; |
312 } | 318 } |
313 } | 319 } |
314 | 320 |
426 char *p, *val; | 432 char *p, *val; |
427 | 433 |
428 if (type == ET_ERROR) | 434 if (type == ET_ERROR) |
429 { | 435 { |
430 *should_free = TRUE; | 436 *should_free = TRUE; |
431 mesg = ((struct msglist *)value)->throw_msg; | 437 mesg = ((msglist_T *)value)->throw_msg; |
432 if (cmdname != NULL && *cmdname != NUL) | 438 if (cmdname != NULL && *cmdname != NUL) |
433 { | 439 { |
434 cmdlen = (int)STRLEN(cmdname); | 440 cmdlen = (int)STRLEN(cmdname); |
435 ret = (char *)vim_strnsave((char_u *)"Vim(", | 441 ret = (char *)vim_strnsave((char_u *)"Vim(", |
436 4 + cmdlen + 2 + (int)STRLEN(mesg)); | 442 4 + cmdlen + 2 + (int)STRLEN(mesg)); |
524 goto nomem; | 530 goto nomem; |
525 | 531 |
526 if (type == ET_ERROR) | 532 if (type == ET_ERROR) |
527 // Store the original message and prefix the exception value with | 533 // Store the original message and prefix the exception value with |
528 // "Vim:" or, if a command name is given, "Vim(cmdname):". | 534 // "Vim:" or, if a command name is given, "Vim(cmdname):". |
529 excp->messages = (struct msglist *)value; | 535 excp->messages = (msglist_T *)value; |
530 | 536 |
531 excp->value = get_exception_string(value, type, cmdname, &should_free); | 537 excp->value = get_exception_string(value, type, cmdname, &should_free); |
532 if (excp->value == NULL && should_free) | 538 if (excp->value == NULL && should_free) |
533 goto nomem; | 539 goto nomem; |
534 | 540 |
535 excp->type = type; | 541 excp->type = type; |
536 excp->throw_name = estack_sfile(); | 542 if (type == ET_ERROR && ((msglist_T *)value)->sfile != NULL) |
537 if (excp->throw_name == NULL) | 543 { |
538 excp->throw_name = vim_strsave((char_u *)""); | 544 msglist_T *entry = (msglist_T *)value; |
539 if (excp->throw_name == NULL) | 545 |
540 { | 546 excp->throw_name = entry->sfile; |
541 if (should_free) | 547 entry->sfile = NULL; |
542 vim_free(excp->value); | 548 excp->throw_lnum = entry->slnum; |
543 goto nomem; | 549 } |
544 } | 550 else |
545 excp->throw_lnum = SOURCING_LNUM; | 551 { |
552 excp->throw_name = estack_sfile(); | |
553 if (excp->throw_name == NULL) | |
554 excp->throw_name = vim_strsave((char_u *)""); | |
555 if (excp->throw_name == NULL) | |
556 { | |
557 if (should_free) | |
558 vim_free(excp->value); | |
559 goto nomem; | |
560 } | |
561 excp->throw_lnum = SOURCING_LNUM; | |
562 } | |
546 | 563 |
547 if (p_verbose >= 13 || debug_break_level > 0) | 564 if (p_verbose >= 13 || debug_break_level > 0) |
548 { | 565 { |
549 int save_msg_silent = msg_silent; | 566 int save_msg_silent = msg_silent; |
550 | 567 |