]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.2261: Vim9: boolean option gets string type v8.2.2261
authorBram Moolenaar <Bram@vim.org>
Fri, 1 Jan 2021 13:49:15 +0000 (14:49 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 1 Jan 2021 13:49:15 +0000 (14:49 +0100)
Problem:    Vim9: boolean option gets string type.
Solution:   Check for VAR_BOOL. (closes #7588)

src/testdir/test_vim9_expr.vim
src/version.c
src/vim9compile.c

index c6a6829fd01f318ad35459dd32012c84a9c13375..e77c1f7e6d9d3563ca5d05b98e8529e8300b70ef 100644 (file)
@@ -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()
index a1b32e853fe861cf9fb99501ab0be0257a398249..b016c289e5be58000192ce158e581d99aa7250c5 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2261,
 /**/
     2260,
 /**/
index b483a60941ed3641e019d4ee428886433a04e0b3..d44fe487c64771e9c38d9cc4ceb9326e98b2bcc6 100644 (file)
@@ -3172,8 +3172,9 @@ compile_get_option(char_u **arg, cctx_T *cctx)
     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);