Patch 8.2.1668

4 views
Skip to first unread message

Bram Moolenaar

unread,
Sep 12, 2020, 1:12:05 PM9/12/20
to vim...@googlegroups.com

Patch 8.2.1668
Problem: Vim9: not accepting 0 or 1 as bool when type is any.
Solution: Convert the type with the CHECKTYPE instruction. (closes #6913)
Files: src/vim9execute.c, src/testdir/test_vim9_expr.vim


*** ../vim-8.2.1667/src/vim9execute.c 2020-09-10 22:05:05.157479076 +0200
--- src/vim9execute.c 2020-09-12 19:09:48.859535809 +0200
***************
*** 2510,2520 ****
|| (tv->v_type == VAR_FUNC
&& ct->ct_type == VAR_PARTIAL)))
{
! SOURCING_LNUM = iptr->isn_lnum;
! semsg(_(e_expected_str_but_got_str),
! vartype_name(ct->ct_type),
! vartype_name(tv->v_type));
! goto on_error;
}
}
break;
--- 2510,2532 ----
|| (tv->v_type == VAR_FUNC
&& ct->ct_type == VAR_PARTIAL)))
{
! if (tv->v_type == VAR_NUMBER && ct->ct_type == VAR_BOOL
! && (tv->vval.v_number == 0
! || tv->vval.v_number == 1))
! {
! // number 0 is FALSE, number 1 is TRUE
! tv->v_type = VAR_BOOL;
! tv->vval.v_number = tv->vval.v_number
! ? VVAL_TRUE : VVAL_FALSE;
! }
! else
! {
! SOURCING_LNUM = iptr->isn_lnum;
! semsg(_(e_expected_str_but_got_str),
! vartype_name(ct->ct_type),
! vartype_name(tv->v_type));
! goto on_error;
! }
}
}
break;
*** ../vim-8.2.1667/src/testdir/test_vim9_expr.vim 2020-09-09 18:54:39.170253618 +0200
--- src/testdir/test_vim9_expr.vim 2020-09-12 19:09:20.579567954 +0200
***************
*** 2369,2374 ****
--- 2369,2377 ----
type: '',
module: ''}
], getloclist(0))
+
+ let result: bool = get(#{n: 0}, 'n', 0)
+ assert_equal(false, result)
enddef

func Test_expr7_trailing_fails()
*** ../vim-8.2.1667/src/version.c 2020-09-12 18:32:30.683427305 +0200
--- src/version.c 2020-09-12 19:10:03.699517907 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 1668,
/**/

--
It is illegal for a driver to be blindfolded while operating a vehicle.
[real standing law in Alabama, United States of America]

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages