Patch 9.0.0090
Problem:    No error when assigning bool to a string option with setwinvar().
Solution:   Give an error (closes #10766)
Files:      src/option.c, src/proto/option.pro, src/evalvars.c,
            src/testdir/test_vim9_builtin.vim


*** ../vim-9.0.0089/src/option.c        2022-07-04 21:03:33.107829279 +0100
--- src/option.c        2022-07-27 12:13:04.323549427 +0100
***************
*** 4478,4483 ****
--- 4478,4497 ----
  }
  #endif
  
+ #if defined(FEAT_EVAL) || defined(PROTO)
+ /*
+  * Return TRUE if "name" is a string option.
+  * Returns FALSE if option "name" does not exist.
+  */
+     int
+ is_string_option(char_u *name)
+ {
+     int idx = findoption(name);
+ 
+     return idx >= 0 && (options[idx].flags & P_STRING);
+ }
+ #endif
+ 
  /*
   * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
   * When "has_lt" is true there is a '<' before "*arg_arg".
*** ../vim-9.0.0089/src/proto/option.pro        2022-06-27 23:15:18.000000000 
+0100
--- src/proto/option.pro        2022-07-27 12:11:24.699756165 +0100
***************
*** 43,48 ****
--- 43,49 ----
  char_u *get_highlight_default(void);
  char_u *get_encoding_default(void);
  int is_option_allocated(char *name);
+ int is_string_option(char_u *name);
  int makeset(FILE *fd, int opt_flags, int local_only);
  int makefoldset(FILE *fd);
  void clear_termoptions(void);
*** ../vim-9.0.0089/src/evalvars.c      2022-07-25 12:28:05.844483996 +0100
--- src/evalvars.c      2022-07-27 12:12:53.751571740 +0100
***************
*** 4223,4228 ****
--- 4223,4233 ----
  
      if (varp->v_type == VAR_BOOL)
      {
+       if (is_string_option(varname))
+       {
+           emsg(_(e_string_required));
+           return;
+       }
        numval = (long)varp->vval.v_number;
        strval = (char_u *)"0";  // avoid using "false"
      }
*** ../vim-9.0.0089/src/testdir/test_vim9_builtin.vim   2022-06-29 
12:54:48.068572061 +0100
--- src/testdir/test_vim9_builtin.vim   2022-07-27 12:16:15.199134024 +0100
***************
*** 3719,3724 ****
--- 3719,3725 ----
    v9.CheckDefAndScriptFailure(['setwinvar("a", "b", 1)'], ['E1013: Argument 
1: type mismatch, expected number but got string', 'E1210: Number required for 
argument 1'])
    v9.CheckDefAndScriptFailure(['setwinvar(1, 2, "c")'], ['E1013: Argument 2: 
type mismatch, expected string but got number', 'E1174: String required for 
argument 2'])
    assert_fails('setwinvar(1, "", 10)', 'E461: Illegal variable name')
+   assert_fails('setwinvar(0, "&rulerformat", true)', 'E928:')
  enddef
  
  def Test_sha256()
*** ../vim-9.0.0089/src/version.c       2022-07-26 22:01:32.377972135 +0100
--- src/version.c       2022-07-27 12:08:48.884061105 +0100
***************
*** 737,738 ****
--- 737,740 ----
  {   /* Add new patch number below this line */
+ /**/
+     90,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
148. You find it easier to dial-up the National Weather Service
     Weather/your_town/now.html than to simply look out the window.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220727113051.A57291C0DF1%40moolenaar.net.

Raspunde prin e-mail lui