Yukihiro Nakadaira wrote:
> When assigning or deleting list item no error raised for out-of-range index.
>
> :let list = []
> :let list[0] = 0
> :echo list
> []
>
> :let list = []
> :unlet list[0]
>
> I expected "E684: list index out of range: 0" or similar error.
Indeed. Strange that nobody noticed the error message is missing.
> And slice assignment do nothing for empty slice.
>
> :let list = []
> :let list[0:9] = [1, 2]
> :echo list
> []
>
> :let list = [0]
> :let list[9:] = [1, 2]
> :echo list
> [0]
>
> :let list = []
> :let list[:] = [1, 2]
> :echo list
> []
>
> For non-empty slice, value is assigned and/or error is raised instead.
>
> :let list = [0]
> :let list[0:9] = [1, 2]
> E711: List value has not enough items
> :echo list
> [1, 2]
>
> :let list = [0]
> :let list[0:0] = [1, 2]
> E710: List value has more items than target
> :echo list
> [1]
>
> :let list = [0]
> :let list[:] = [1, 2]
> :echo list
> [1, 2]
I'm preparing a patch to fix this. Hopefully it doesn't go the other
way, giving an error message when it should not.
--
Bypasses are devices that allow some people to dash from point A to
point B very fast while other people dash from point B to point A very
fast. People living at point C, being a point directly in between, are
often given to wonder what's so great about point A that so many people
from point B are so keen to get there and what's so great about point B
that so many people from point A are so keen to get there. They often
wish that people would just once and for all work out where the hell
they wanted to be.
-- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
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