diff 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
line wrap: on
line diff
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -3630,6 +3630,15 @@ tv2bool(typval_T *tv)
     return FALSE;
 }
 
+    void
+emsg_using_string_as(typval_T *tv, int as_number)
+{
+    semsg(_(as_number ? e_using_string_as_number_str
+						 : e_using_string_as_bool_str),
+		       tv->vval.v_string == NULL
+					   ? (char_u *)"" : tv->vval.v_string);
+}
+
 /*
  * If "tv" is a string give an error and return FAIL.
  */
@@ -3638,7 +3647,7 @@ check_not_string(typval_T *tv)
 {
     if (tv->v_type == VAR_STRING)
     {
-	emsg(_(e_using_string_as_number));
+	emsg_using_string_as(tv, TRUE);
 	clear_tv(tv);
 	return FAIL;
     }