diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-07-04 09:54:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-04 09:54:51 +0800 |
commit | 033ea63b2fa2c0ce1a47bafd97df482871aafef5 (patch) | |
tree | 52521994df183ef6ca4671fbef2c57a75f356771 | |
parent | 7f33c1967b78ca8fda11fb0ad4c7f57d563e6ede (diff) | |
download | rneovim-033ea63b2fa2c0ce1a47bafd97df482871aafef5.tar.gz rneovim-033ea63b2fa2c0ce1a47bafd97df482871aafef5.tar.bz2 rneovim-033ea63b2fa2c0ce1a47bafd97df482871aafef5.zip |
refactor: add assertion for v_blob in tv_ptr() (#29554)
Also add test for using printf() and id() with a Blob.
-rw-r--r-- | src/nvim/strings.c | 6 | ||||
-rw-r--r-- | test/functional/vimscript/printf_spec.lua | 3 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/nvim/strings.c b/src/nvim/strings.c index bf7af40a38..0aaa100bf2 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -629,12 +629,14 @@ static const void *tv_ptr(const typval_T *const tvs, int *const idxp) #define OFF(attr) offsetof(union typval_vval_union, attr) STATIC_ASSERT(OFF(v_string) == OFF(v_list) && OFF(v_string) == OFF(v_dict) + && OFF(v_string) == OFF(v_blob) && OFF(v_string) == OFF(v_partial) && sizeof(tvs[0].vval.v_string) == sizeof(tvs[0].vval.v_list) && sizeof(tvs[0].vval.v_string) == sizeof(tvs[0].vval.v_dict) + && sizeof(tvs[0].vval.v_string) == sizeof(tvs[0].vval.v_blob) && sizeof(tvs[0].vval.v_string) == sizeof(tvs[0].vval.v_partial), - "Strings, dictionaries, lists and partials are expected to be pointers, " - "so that all three of them can be accessed via v_string"); + "Strings, Dictionaries, Lists, Blobs and Partials are expected to be pointers, " + "so that all of them can be accessed via v_string"); #undef OFF const int idx = *idxp - 1; if (tvs[idx].v_type == VAR_UNKNOWN) { diff --git a/test/functional/vimscript/printf_spec.lua b/test/functional/vimscript/printf_spec.lua index 3c66e07618..1fd5c3c9b6 100644 --- a/test/functional/vimscript/printf_spec.lua +++ b/test/functional/vimscript/printf_spec.lua @@ -84,10 +84,13 @@ describe('printf()', function() end api.nvim_del_var('__result') end + check_printf('v:_null_string', true) check_printf('v:_null_list', true) check_printf('v:_null_dict', true) + check_printf('v:_null_blob', true) check_printf('[]') check_printf('{}') + check_printf('0z') check_printf('function("tr", ["a"])') end) end) |