vim-patch:8.2.1600: Vim9: cannot use "true" with deepcopy()

Problem:    Vim9: cannot use "true" with deepcopy().
Solution:   Use tv_get_bool_chk(). (closes vim/vim#6867)

44b4a246b6

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq
2022-11-05 17:43:38 +08:00
parent e25193143b
commit 38c113ae84
2 changed files with 3 additions and 3 deletions

View File

@@ -1360,7 +1360,7 @@ static void f_deepcopy(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
int noref = 0;
if (argvars[1].v_type != VAR_UNKNOWN) {
noref = (int)tv_get_number_chk(&argvars[1], NULL);
noref = (int)tv_get_bool_chk(&argvars[1], NULL);
}
if (noref < 0 || noref > 1) {
semsg(_(e_using_number_as_bool_nr), noref);

View File

@@ -336,12 +336,12 @@ func Test_dict_deepcopy()
let l = [4, d, 6]
let d[3] = l
let dc = deepcopy(d)
call assert_fails('call deepcopy(d, 1)', 'E698')
call assert_fails('call deepcopy(d, 1)', 'E698:')
let l2 = [0, l, l, 3]
let l[1] = l2
let l3 = deepcopy(l2)
call assert_true(l3[1] is l3[2])
call assert_fails("call deepcopy([1, 2], 2)", 'E474:')
call assert_fails("call deepcopy([1, 2], 2)", 'E1023:')
endfunc
" Locked variables