Mercurial > vim
comparison src/vim9execute.c @ 22860:53acb89ec9f2 v8.2.1977
patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Commit: https://github.com/vim/vim/commit/ea2d407f9c144bb634c59017944e4930ed7f80a2
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Nov 12 12:08:51 2020 +0100
patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Problem: Vim9: error for using a string in a condition is confusing.
Solution: Give a more specific error. Also adjust the compile time type
checking for || and &&.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 12 Nov 2020 12:15:04 +0100 |
parents | 2d05dd71aac3 |
children | 54219df706b5 |
comparison
equal
deleted
inserted
replaced
22859:757858b35433 | 22860:53acb89ec9f2 |
---|---|
3628 break; | 3628 break; |
3629 } | 3629 } |
3630 return FALSE; | 3630 return FALSE; |
3631 } | 3631 } |
3632 | 3632 |
3633 void | |
3634 emsg_using_string_as(typval_T *tv, int as_number) | |
3635 { | |
3636 semsg(_(as_number ? e_using_string_as_number_str | |
3637 : e_using_string_as_bool_str), | |
3638 tv->vval.v_string == NULL | |
3639 ? (char_u *)"" : tv->vval.v_string); | |
3640 } | |
3641 | |
3633 /* | 3642 /* |
3634 * If "tv" is a string give an error and return FAIL. | 3643 * If "tv" is a string give an error and return FAIL. |
3635 */ | 3644 */ |
3636 int | 3645 int |
3637 check_not_string(typval_T *tv) | 3646 check_not_string(typval_T *tv) |
3638 { | 3647 { |
3639 if (tv->v_type == VAR_STRING) | 3648 if (tv->v_type == VAR_STRING) |
3640 { | 3649 { |
3641 emsg(_(e_using_string_as_number)); | 3650 emsg_using_string_as(tv, TRUE); |
3642 clear_tv(tv); | 3651 clear_tv(tv); |
3643 return FAIL; | 3652 return FAIL; |
3644 } | 3653 } |
3645 return OK; | 3654 return OK; |
3646 } | 3655 } |