On Thu, Apr 9, 2020 at 5:32 PM Yegappan Lakshmanan <[email protected]> wrote:
>
> Hi all,
>
> 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:

submatch({nr} [, {list}])            *submatch()* *E935*
        Only for an expression in a |:substitute| command or
        substitute() function.

IMHO when used outside if a :substitute command or of a substitute()
function, submatch() should generate an error. (What is the en_US text
of error E935?)

Best regards,
Tony.

-- 
-- 
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/CAJkCKXsNLimBc1rmKk%3DPwzVJMyEyr%3DCH-yE6aF8C9oqupMx58g%40mail.gmail.com.

Raspunde prin e-mail lui