Mercurial > vim
comparison src/eval.c @ 15478:051937ebaf22 v8.1.0747
patch 8.1.0747: map() with a bad expression doesn't give an error
commit https://github.com/vim/vim/commit/ce9d50df07402cb8e196537a9c4505845adecabc
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jan 14 22:22:29 2019 +0100
patch 8.1.0747: map() with a bad expression doesn't give an error
Problem: map() with a bad expression doesn't give an error. (Ingo Karkat)
Solution: Check for giving an error message. (closes https://github.com/vim/vim/issues/3800)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 14 Jan 2019 22:30:07 +0100 |
parents | 55ccc2d353bd |
children | 18dd04f7c4a1 |
comparison
equal
deleted
inserted
replaced
15477:78ab210dc537 | 15478:051937ebaf22 |
---|---|
694 --emsg_skip; | 694 --emsg_skip; |
695 | 695 |
696 return (int)retval; | 696 return (int)retval; |
697 } | 697 } |
698 | 698 |
699 /* | |
700 * Call eval1() and give an error message if not done at a lower level. | |
701 */ | |
702 static int | |
703 eval1_emsg(char_u **arg, typval_T *rettv, int evaluate) | |
704 { | |
705 int ret; | |
706 int did_emsg_before = did_emsg; | |
707 int called_emsg_before = called_emsg; | |
708 | |
709 ret = eval1(arg, rettv, evaluate); | |
710 if (ret == FAIL) | |
711 { | |
712 // Report the invalid expression unless the expression evaluation has | |
713 // been cancelled due to an aborting error, an interrupt, or an | |
714 // exception, or we already gave a more specific error. | |
715 // Also check called_emsg for when using assert_fails(). | |
716 if (!aborting() && did_emsg == did_emsg_before | |
717 && called_emsg == called_emsg_before) | |
718 semsg(_(e_invexpr2), arg); | |
719 } | |
720 return ret; | |
721 } | |
722 | |
699 static int | 723 static int |
700 eval_expr_typval(typval_T *expr, typval_T *argv, int argc, typval_T *rettv) | 724 eval_expr_typval(typval_T *expr, typval_T *argv, int argc, typval_T *rettv) |
701 { | 725 { |
702 char_u *s; | 726 char_u *s; |
703 int dummy; | 727 int dummy; |
727 { | 751 { |
728 s = tv_get_string_buf_chk(expr, buf); | 752 s = tv_get_string_buf_chk(expr, buf); |
729 if (s == NULL) | 753 if (s == NULL) |
730 return FAIL; | 754 return FAIL; |
731 s = skipwhite(s); | 755 s = skipwhite(s); |
732 if (eval1(&s, rettv, TRUE) == FAIL) | 756 if (eval1_emsg(&s, rettv, TRUE) == FAIL) |
733 return FAIL; | 757 return FAIL; |
734 if (*s != NUL) /* check for trailing chars after expr */ | 758 if (*s != NUL) /* check for trailing chars after expr */ |
735 { | 759 { |
736 clear_tv(rettv); | 760 clear_tv(rettv); |
737 semsg(_(e_invexpr2), s); | 761 semsg(_(e_invexpr2), s); |
8462 if (eap->skip) | 8486 if (eap->skip) |
8463 ++emsg_skip; | 8487 ++emsg_skip; |
8464 while (*arg != NUL && *arg != '|' && *arg != '\n') | 8488 while (*arg != NUL && *arg != '|' && *arg != '\n') |
8465 { | 8489 { |
8466 p = arg; | 8490 p = arg; |
8467 if (eval1(&arg, &rettv, !eap->skip) == FAIL) | 8491 ret = eval1_emsg(&arg, &rettv, !eap->skip); |
8468 { | 8492 if (ret == FAIL) |
8469 /* | |
8470 * Report the invalid expression unless the expression evaluation | |
8471 * has been cancelled due to an aborting error, an interrupt, or an | |
8472 * exception. | |
8473 */ | |
8474 if (!aborting() && did_emsg == save_did_emsg) | |
8475 semsg(_(e_invexpr2), p); | |
8476 ret = FAIL; | |
8477 break; | 8493 break; |
8478 } | |
8479 | 8494 |
8480 if (!eap->skip) | 8495 if (!eap->skip) |
8481 { | 8496 { |
8482 char_u buf[NUMBUFLEN]; | 8497 char_u buf[NUMBUFLEN]; |
8483 | 8498 |
10756 } | 10771 } |
10757 } | 10772 } |
10758 } | 10773 } |
10759 else | 10774 else |
10760 { | 10775 { |
10776 // argvars[0].v_type == VAR_LIST | |
10761 vimvars[VV_KEY].vv_type = VAR_NUMBER; | 10777 vimvars[VV_KEY].vv_type = VAR_NUMBER; |
10762 | 10778 |
10763 for (li = l->lv_first; li != NULL; li = nli) | 10779 for (li = l->lv_first; li != NULL; li = nli) |
10764 { | 10780 { |
10765 if (map && tv_check_lock(li->li_tv.v_lock, arg_errmsg, TRUE)) | 10781 if (map && tv_check_lock(li->li_tv.v_lock, arg_errmsg, TRUE)) |