changeset 23436:ab163feb30cb v8.2.2261

patch 8.2.2261: Vim9: boolean option gets string type Commit: https://github.com/vim/vim/commit/d5ea8f08f78d20fde8773663894de5e8c023bd83 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jan 1 14:49:15 2021 +0100 patch 8.2.2261: Vim9: boolean option gets string type Problem: Vim9: boolean option gets string type. Solution: Check for VAR_BOOL. (closes https://github.com/vim/vim/issues/7588)
author Bram Moolenaar <Bram@vim.org>
date Fri, 01 Jan 2021 15:00:03 +0100
parents d94ada879d70
children b441dd39a450
files src/testdir/test_vim9_expr.vim src/version.c src/vim9compile.c
diffstat 3 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -2417,6 +2417,11 @@ def Test_expr7_option()
   &grepprg = test_null_string()
   assert_equal('', &grepprg)
   set grepprg&
+
+  # check matching type
+  var bval: bool = &tgc
+  var nval: number = &ts
+  var sval: string = &path
 enddef
 
 def Test_expr7_environment()
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2261,
+/**/
     2260,
 /**/
     2259,
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -3172,8 +3172,9 @@ compile_get_option(char_u **arg, cctx_T 
     if (ret == OK)
     {
 	// include the '&' in the name, eval_option() expects it.
-	char_u *name = vim_strnsave(start, *arg - start);
-	type_T	*type = rettv.v_type == VAR_NUMBER ? &t_number : &t_string;
+	char_u	*name = vim_strnsave(start, *arg - start);
+	type_T	*type = rettv.v_type == VAR_BOOL ? &t_bool
+			  : rettv.v_type == VAR_NUMBER ? &t_number : &t_string;
 
 	ret = generate_LOAD(cctx, ISN_LOADOPT, 0, name, type);
 	vim_free(name);