]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.1.0220: Ruby converts v:true and v:false to a number v8.1.0220
authorBram Moolenaar <Bram@vim.org>
Sat, 28 Jul 2018 15:18:09 +0000 (17:18 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 28 Jul 2018 15:18:09 +0000 (17:18 +0200)
Problem:    Ruby converts v:true and v:false to a number.
Solution:   Use Qtrue and Qfalse instead. (Masataka Pocke Kuwabara,
            closes #3259)

src/if_ruby.c
src/testdir/test_ruby.vim
src/version.c

index 4b9af318d2acbc65d23557affc54ad99b6b635e4..2e1f8d75aef72749b97d9f7d329a8098eaf43305 100644 (file)
@@ -1085,8 +1085,10 @@ static VALUE vim_to_ruby(typval_T *tv)
     }
     else if (tv->v_type == VAR_SPECIAL)
     {
-       if (tv->vval.v_number <= VVAL_TRUE)
-           result = INT2NUM(tv->vval.v_number);
+       if (tv->vval.v_number == VVAL_TRUE)
+           result = Qtrue;
+       else if (tv->vval.v_number == VVAL_FALSE)
+           result = Qfalse;
     } /* else return Qnil; */
 
     return result;
index ae27b39cd31453657877927d6dc924b8da1a9dd8..36442fcbcaf661415c642eb04184f46124e3de2c 100644 (file)
@@ -33,6 +33,14 @@ func Test_ruby_evaluate_dict()
   call assert_equal(['{"a"=>"foo", "b"=>123}'], split(l:out, "\n"))
 endfunc
 
+func Test_ruby_evaluate_special_var()
+  let l = [v:true, v:false, v:null, v:none]
+  redir => l:out
+  ruby d = Vim.evaluate("l"); print d
+  redir END
+  call assert_equal(['[true, false, nil, nil]'], split(l:out, "\n"))
+endfunc
+
 func Test_rubydo()
   " Check deleting lines does not trigger ml_get error.
   new
index 4ea5c75bf9fbe91f4b556daeae05f7f991dd67be..d69a8c73d69827ac6f75dbb582ca1733bbbfd995 100644 (file)
@@ -798,6 +798,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    220,
 /**/
     219,
 /**/