Hi Tony,

On Thu, Apr 9, 2020 at 9:03 AM Tony Mechelynck <[email protected]>
wrote:

> 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:
>


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.

Regards,
Yegappan



>
> 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/CAAW7x7mupQHfu9eRg2Vbu_SaZ6e-xVBtn1NpA-9uthr8jTbKhg%40mail.gmail.com.

Raspunde prin e-mail lui