diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-03-01 23:23:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-01 23:23:39 +0800 |
commit | f25d126b186e187f539a909824804d4bc88380e0 (patch) | |
tree | 235a4efe9c59e7cf671b2c47be3a0b56f4bcefc4 | |
parent | 896d672736b32a8f4a4fa51844b44f266dcdcc6c (diff) | |
download | rneovim-f25d126b186e187f539a909824804d4bc88380e0.tar.gz rneovim-f25d126b186e187f539a909824804d4bc88380e0.tar.bz2 rneovim-f25d126b186e187f539a909824804d4bc88380e0.zip |
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.
https://github.com/vim/vim/commit/b7c21afef14bba0208f2c40d47c050a004eb2f34
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)
https://github.com/vim/vim/commit/348be7ed07d164970ec0004bc278e254eb0cf5bf
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>
-rw-r--r-- | src/nvim/testdir/test_blob.vim | 56 |
1 files changed, 44 insertions, 12 deletions
diff --git a/src/nvim/testdir/test_blob.vim b/src/nvim/testdir/test_blob.vim index 2c145f2019..920ceb826d 100644 --- a/src/nvim/testdir/test_blob.vim +++ b/src/nvim/testdir/test_blob.vim @@ -317,27 +317,59 @@ func Test_blob_for_loop() endfunc func Test_blob_concatenate() - let b = 0z0011 - let b += 0z2233 - call assert_equal(0z00112233, b) + let lines =<< trim END + VAR b = 0z0011 + LET b += 0z2233 + call assert_equal(0z00112233, b) - call assert_fails('let b += "a"') - call assert_fails('let b += 88') + LET b = 0zDEAD + 0zBEEF + call assert_equal(0zDEADBEEF, b) + END + call CheckLegacyAndVim9Success(lines) - let b = 0zDEAD + 0zBEEF - call assert_equal(0zDEADBEEF, b) + let lines =<< trim END + 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 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 - call add(b, 0x22) - call assert_equal(0z001122, b) 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_fails('call add(b, [9])', 'E745:') - call assert_fails('call add("", 0x01)', 'E897:') + let lines =<< trim END + 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 func Test_blob_empty() |