> > > The submatch() function with a second argument set to 1, returns NULL > > > when used outside of a :substitute command or the substitute() function. > > > All the other functions that return a List, return an empty List on > > failure. > > > But the submatch() function returns NULL on failure. e.g. > > > > > > call assert_equal([], submatch(0, 1)) > > > echo v:errors > > > > > > The returned value cannot be compared against NULL. I think the > > submatch() > > > function should be changed to return an empty List. > > > > > > - Yegappan > > > > submatch() is not meant to be used outside of a substitute, it's > > documented: > > > > > Yes. I am developing a test case to verify that submatch() fails when called > outside of a substitute. To do this, usually the returned value is compared > against an empty string or an empty list or an error code. > In this case, the submatch() function is returning NULL. So it is not > possible to check the returned value.
A NULL list means the same as an empty list, but assert_equal() is picky. You can compare with test_null_list(). Hmm, it then says that NULL is not equal NULL. That looks like a bug. I think we should consider a NULL list equal to another NULL list. And most likely also equal to an empty list, since the user can't tell the difference. -- LETTERS TO THE EDITOR (The Times of London) Dear Sir, I am firmly opposed to the spread of microchips either to the home or to the office. We have more than enough of them foisted upon us in public places. They are a disgusting Americanism, and can only result in the farmers being forced to grow smaller potatoes, which in turn will cause massive unemployment in the already severely depressed agricultural industry. Yours faithfully, Capt. Quinton D'Arcy, J. P. Sevenoaks /// 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 --- 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]. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/202004091933.039JXmSc012663%40masaka.moolenaar.net.
