E117 from :return command bypasses try..catch

44 views
Skip to first unread message

David Barnett

unread,
Nov 19, 2013, 10:59:23 PM11/19/13
to vim...@googlegroups.com
I discovered a bug in try..catch. E117 bypasses the catch and always bubbles up to the user if it comes from a :return command in code like the following:
function E_117_Bad() abort
  try
    return foo#Bar()
  catch /.*/
  endtry
endfunction
but not if the exception comes from any other command besides return:
function E_117_Bad() abort
  try
    let l:foo = foo#Bar()
    return l:foo
  catch /.*/
  endtry
endfunction

I tried :call, :echo, and :let, and they all worked as expected. Only :return is weird.

David

Benjamin Klein

unread,
Nov 19, 2013, 11:13:12 PM11/19/13
to vim...@googlegroups.com
On Nov 19, 2013, at 9:59 PM, David Barnett <davie...@gmail.com> wrote:

I discovered a bug in try..catch. E117 bypasses the catch and always bubbles up to the user if it comes from a :return command in code like the following:
function E_117_Bad() abort
  try
    return foo#Bar()
  catch /.*/
  endtry
endfunction

This may be irrelevant but as it isn’t defined here: What is foo#Bar()?

--
b

Sent from my iPhone

David Barnett

unread,
Nov 19, 2013, 11:17:03 PM11/19/13
to vim...@googlegroups.com
On Tue, Nov 19, 2013 at 8:13 PM, Benjamin Klein <b...@silver-chalice.com> wrote:
This may be irrelevant but as it isn’t defined here: What is foo#Bar()?
Heh, that's exactly the point. E117 is "Unknown function" (sorry, should have mentioned that). foo#Bar() was my dummy undefined function.

David

Benjamin Klein

unread,
Nov 19, 2013, 11:33:12 PM11/19/13
to vim...@googlegroups.com
On Nov 19, 2013, at 10:17 PM, David Barnett <davie...@gmail.com> wrote:

> Heh, that's exactly the point. E117 is "Unknown function" (sorry, should have mentioned that). foo#Bar() was my dummy undefined function.

Oops -- sorry. That was dumb of me to not notice, but then again I’m on my phone and can’t as easily look up the error. :D

Nikolay Pavlov

unread,
Nov 19, 2013, 11:52:11 PM11/19/13
to vim...@googlegroups.com

That is why I name such functions like xxx_unknown_function_xxx. No questions with such convention.

> David
>
> --
> --
> 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 vim_dev+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

David Barnett

unread,
Nov 20, 2013, 12:53:46 AM11/20/13
to vim...@googlegroups.com
Yep, sorry, I should have used
  return xxx_unknown_function_xxx()
in my example for clarity, but I didn't think of that until after the fact.

Anyway, I think this is a bug in vim. Also forgot to mention I checked the latest version of vim available, 7.4.94, and the bug still hasn't been fixed.

David


You received this message because you are subscribed to a topic in the Google Groups "vim_dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_dev/SQO6gi1B8aI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vim_dev+u...@googlegroups.com.

Bram Moolenaar

unread,
Nov 20, 2013, 4:24:35 PM11/20/13
to David Barnett, vim...@googlegroups.com
I can reproduce it. Most likely this is caused by the logic to make the
function return even when the exception is caught.

--
Lower life forms have more fun!

/// Bram Moolenaar -- Br...@Moolenaar.net -- 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 ///
Reply all
Reply to author
Forward
0 new messages