On Wednesday, April 20, 2016 at 1:17:35 AM UTC+3, Björn Linse wrote:
> To reproduce:
>
> vim -u NONE -i NONE
> :let x = getreg("a",1,1)
> :call setreg("0",x)
>
> gives SIGSEGV on master vim (huge build). "-i NONE" is needed to make sure
> registers are undefined.
>
> it seems like getreg returns a NULL list (I don't know if that is supposed to
> be a thing) for an undefined register, but setreg doesn't handle it.
>
> Maybe the NULL list is meant to behave like a locked empty list, but then
Fixed, not locked. I refer to VAR_FIXED (i.e. lock that cannot be removed by
:unlockvar) vs VAR_LOCKED (i.e. lock which can). I do not know how NULL list
was *meant* to behave (maybe it is something completely internal which should
not be stored in a variable ever and `getreg()` contains a bug), but there
obviously is no way to make NULL list mutable, so it *cannot* be anything else,
but VAR_FIXED list with constant (currently no) content.
> :call add(x, something)
> should be an error right? Right now it apparently succeeds but len(x) is
> still 0.
---
If NULL lists and dictionaries are something that all functions that accept a
list/a dictionary are supposed to handle I would suggest to
1. Officially make them the same thing as .[dl]v_lock=VAR_FIXED empty
list/dictionary. So add(x, something)/extend(d, something)/… will throw error.
2. Add v:_null_list and v:_null_dict read-only v: variables that may be used in
tests. Such variables would be guaranteed to have .vv_list/.vv_dict equal to
NULL. It should be mentioned somewhere for the developers that functions that
need to accept a list/a dictionary should also handle v:_null_… and this
behaviour should be tested.
Point 2. was already added to Neovim by me, except that I did not document it.
It may make sense to extend this point with v:_null_string, but I was satisfied
enough with $XXX_NONEXISTENT_VARIABLE_XXX hack used to obtain NULL string:
because I could add a test that $XXX… produces NULL string to make sure my
tests continue testing what they were written for. Vim has no unit tests that
directly call C functions, so v:_null_string is required here to make sure
tests continue testing what is needed.
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.