diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-05-25 22:36:50 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-05-25 22:36:50 +0200 |
commit | 25e0f5863e9010a75a1ff0d04e8f886403968755 (patch) | |
tree | bcb0891919dbc85578b8483487f2ef89ede0f93c /src/ex_eval.c | |
parent | 2eec37926db6d31beb36f162ac00357a30c093c8 (diff) | |
download | vim-git-25e0f5863e9010a75a1ff0d04e8f886403968755.tar.gz |
patch 8.2.0823: Vim9: script reload test is disabledv8.2.0823
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.
Diffstat (limited to 'src/ex_eval.c')
-rw-r--r-- | src/ex_eval.c | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/src/ex_eval.c b/src/ex_eval.c index f7253438d..68207cbe7 100644 --- a/src/ex_eval.c +++ b/src/ex_eval.c @@ -146,8 +146,8 @@ cause_errthrow( int severe, int *ignore) { - struct msglist *elem; - struct msglist **plist; + msglist_T *elem; + msglist_T **plist; /* * Do nothing when displaying the interrupt message or reporting an @@ -251,7 +251,7 @@ cause_errthrow( while (*plist != NULL) plist = &(*plist)->next; - elem = ALLOC_ONE(struct msglist); + elem = ALLOC_CLEAR_ONE(msglist_T); if (elem == NULL) { suppress_errthrow = TRUE; @@ -287,6 +287,11 @@ cause_errthrow( else (*msg_list)->throw_msg = tmsg; } + + // Get the source name and lnum now, it may change before + // reaching do_errthrow(). + elem->sfile = estack_sfile(); + elem->slnum = SOURCING_LNUM; } } } @@ -298,15 +303,16 @@ cause_errthrow( * Free a "msg_list" and the messages it contains. */ static void -free_msglist(struct msglist *l) +free_msglist(msglist_T *l) { - struct msglist *messages, *next; + msglist_T *messages, *next; messages = l; while (messages != NULL) { next = messages->next; vim_free(messages->msg); + vim_free(messages->sfile); vim_free(messages); messages = next; } @@ -428,7 +434,7 @@ get_exception_string( if (type == ET_ERROR) { *should_free = TRUE; - mesg = ((struct msglist *)value)->throw_msg; + mesg = ((msglist_T *)value)->throw_msg; if (cmdname != NULL && *cmdname != NUL) { cmdlen = (int)STRLEN(cmdname); @@ -526,23 +532,34 @@ throw_exception(void *value, except_type_T type, char_u *cmdname) if (type == ET_ERROR) // Store the original message and prefix the exception value with // "Vim:" or, if a command name is given, "Vim(cmdname):". - excp->messages = (struct msglist *)value; + excp->messages = (msglist_T *)value; excp->value = get_exception_string(value, type, cmdname, &should_free); if (excp->value == NULL && should_free) goto nomem; excp->type = type; - excp->throw_name = estack_sfile(); - if (excp->throw_name == NULL) - excp->throw_name = vim_strsave((char_u *)""); - if (excp->throw_name == NULL) + if (type == ET_ERROR && ((msglist_T *)value)->sfile != NULL) { - if (should_free) - vim_free(excp->value); - goto nomem; + msglist_T *entry = (msglist_T *)value; + + excp->throw_name = entry->sfile; + entry->sfile = NULL; + excp->throw_lnum = entry->slnum; + } + else + { + excp->throw_name = estack_sfile(); + if (excp->throw_name == NULL) + excp->throw_name = vim_strsave((char_u *)""); + if (excp->throw_name == NULL) + { + if (should_free) + vim_free(excp->value); + goto nomem; + } + excp->throw_lnum = SOURCING_LNUM; } - excp->throw_lnum = SOURCING_LNUM; if (p_verbose >= 13 || debug_break_level > 0) { |