Skip to content

Commit d84b26a

Browse files
committed
patch 8.1.0220: Ruby converts v:true and v:false to a number
Problem: Ruby converts v:true and v:false to a number. Solution: Use Qtrue and Qfalse instead. (Masataka Pocke Kuwabara, closes #3259)
1 parent 2c8c681 commit d84b26a

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/if_ruby.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,8 +1085,10 @@ static VALUE vim_to_ruby(typval_T *tv)
10851085
}
10861086
else if (tv->v_type == VAR_SPECIAL)
10871087
{
1088-
if (tv->vval.v_number <= VVAL_TRUE)
1089-
result = INT2NUM(tv->vval.v_number);
1088+
if (tv->vval.v_number == VVAL_TRUE)
1089+
result = Qtrue;
1090+
else if (tv->vval.v_number == VVAL_FALSE)
1091+
result = Qfalse;
10901092
} /* else return Qnil; */
10911093

10921094
return result;

src/testdir/test_ruby.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ func Test_ruby_evaluate_dict()
3333
call assert_equal(['{"a"=>"foo", "b"=>123}'], split(l:out, "\n"))
3434
endfunc
3535

36+
func Test_ruby_evaluate_special_var()
37+
let l = [v:true, v:false, v:null, v:none]
38+
redir => l:out
39+
ruby d = Vim.evaluate("l"); print d
40+
redir END
41+
call assert_equal(['[true, false, nil, nil]'], split(l:out, "\n"))
42+
endfunc
43+
3644
func Test_rubydo()
3745
" Check deleting lines does not trigger ml_get error.
3846
new

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,8 @@ static char *(features[]) =
798798

799799
static int included_patches[] =
800800
{ /* Add new patch number below this line */
801+
/**/
802+
220,
801803
/**/
802804
219,
803805
/**/

0 commit comments

Comments
 (0)