]> granicus.if.org Git - vim/commitdiff
patch 8.2.4492: no error if an option is given a value with ":let &opt = val" v8.2.4492
authorBram Moolenaar <Bram@vim.org>
Wed, 2 Mar 2022 19:49:38 +0000 (19:49 +0000)
committerBram Moolenaar <Bram@vim.org>
Wed, 2 Mar 2022 19:49:38 +0000 (19:49 +0000)
Problem:    No error if an option is given an invalid value with
            ":let &opt = val".
Solution:   Give the error. (closes #9864)

src/evalvars.c
src/testdir/test_options.vim
src/version.c

index 862d5192bb4e5fbc9cf386ae2b8c2033098014aa..eb69d3e2086df499b7dcacdb59b7e1027810234c 100644 (file)
@@ -1518,8 +1518,11 @@ ex_let_option(
        {
            if (opt_type != gov_string || s != NULL)
            {
-               set_option_value(arg, n, s, scope);
+               char *err = set_option_value(arg, n, s, scope);
+
                arg_end = p;
+               if (err != NULL)
+                   emsg(_(err));
            }
            else
                emsg(_(e_string_required));
index 9ba2ce441ef10c3d1c607ec4ecbafdfb782df4e5..81081f5020d9dc30067c3817e9cfc12a3f877ced 100644 (file)
@@ -369,6 +369,7 @@ func Test_set_errors()
   call assert_fails('set sidescroll=-1', 'E487:')
   call assert_fails('set tabstop=-1', 'E487:')
   call assert_fails('set tabstop=10000', 'E474:')
+  call assert_fails('let &tabstop = 10000', 'E474:')
   call assert_fails('set tabstop=5500000000', 'E474:')
   call assert_fails('set textwidth=-1', 'E487:')
   call assert_fails('set timeoutlen=-1', 'E487:')
@@ -384,6 +385,7 @@ func Test_set_errors()
   call assert_fails('set comments=a', 'E525:')
   call assert_fails('set foldmarker=x', 'E536:')
   call assert_fails('set commentstring=x', 'E537:')
+  call assert_fails('let &commentstring = "x"', 'E537:')
   call assert_fails('set complete=x', 'E539:')
   call assert_fails('set rulerformat=%-', 'E539:')
   call assert_fails('set rulerformat=%(', 'E542:')
index 12d4f6eb001fe27ae4d8d263043b392edf988105..2b61254d46ef5e42a7d741d4a3e99705687a5627 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4492,
 /**/
     4491,
 /**/