mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.{1949,2781} (#22451)
vim-patch:8.2.2781: add() silently skips when adding to null list or blob Problem: Add() silently skips when adding to null list or blob. Solution: Give an error in Vim9 script. Allocate blob when it is NULL like with list and dict.b7c21afef1
Do not implicitly change a NULL blob/dict/list to an empty one. N/A patches for version.c: vim-patch:8.2.1949: Vim9: using extend() on null dict is silently ignored Problem: Vim9: using extend() on null dict is silently ignored. Solution: Give an error message. Initialize a dict variable with an empty dictionary. (closes vim/vim#7251)348be7ed07
N/A because Nvim's current behavior is an error message as a locked list/dict, which is more consistent. Ref #4615. Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
896d672736
commit
f25d126b18
@ -317,27 +317,59 @@ func Test_blob_for_loop()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_blob_concatenate()
|
func Test_blob_concatenate()
|
||||||
let b = 0z0011
|
let lines =<< trim END
|
||||||
let b += 0z2233
|
VAR b = 0z0011
|
||||||
call assert_equal(0z00112233, b)
|
LET b += 0z2233
|
||||||
|
call assert_equal(0z00112233, b)
|
||||||
|
|
||||||
call assert_fails('let b += "a"')
|
LET b = 0zDEAD + 0zBEEF
|
||||||
call assert_fails('let b += 88')
|
call assert_equal(0zDEADBEEF, b)
|
||||||
|
END
|
||||||
|
call CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
let b = 0zDEAD + 0zBEEF
|
let lines =<< trim END
|
||||||
call assert_equal(0zDEADBEEF, b)
|
VAR b = 0z0011
|
||||||
|
LET b += "a"
|
||||||
|
END
|
||||||
|
call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:'])
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
VAR b = 0z0011
|
||||||
|
LET b += 88
|
||||||
|
END
|
||||||
|
call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:'])
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_blob_add()
|
func Test_blob_add()
|
||||||
|
let lines =<< trim END
|
||||||
|
VAR b = 0z0011
|
||||||
|
call add(b, 0x22)
|
||||||
|
call assert_equal(0z001122, b)
|
||||||
|
END
|
||||||
|
call CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
|
" Only works in legacy script
|
||||||
let b = 0z0011
|
let b = 0z0011
|
||||||
call add(b, 0x22)
|
|
||||||
call assert_equal(0z001122, b)
|
|
||||||
call add(b, '51')
|
call add(b, '51')
|
||||||
call assert_equal(0z00112233, b)
|
call assert_equal(0z001133, b)
|
||||||
call assert_equal(1, add(v:_null_blob, 0x22))
|
call assert_equal(1, add(v:_null_blob, 0x22))
|
||||||
|
|
||||||
call assert_fails('call add(b, [9])', 'E745:')
|
let lines =<< trim END
|
||||||
call assert_fails('call add("", 0x01)', 'E897:')
|
VAR b = 0z0011
|
||||||
|
call add(b, [9])
|
||||||
|
END
|
||||||
|
call CheckLegacyAndVim9Failure(lines, ['E745:', 'E1012:', 'E745:'])
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
VAR b = 0z0011
|
||||||
|
call add("", 0x01)
|
||||||
|
END
|
||||||
|
call CheckLegacyAndVim9Failure(lines, 'E897:')
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
add(v:_null_blob, 0x22)
|
||||||
|
END
|
||||||
|
call CheckDefExecAndScriptFailure(lines, 'E1131:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_blob_empty()
|
func Test_blob_empty()
|
||||||
|
Loading…
Reference in New Issue
Block a user