Re: Bug in exception handling with :return

2008-09-15 Fir de Conversatie Bram Moolenaar


Matt Wozniski wrote:

 These two functions ought to behave identically, but don't... For some
 reason, the :catch never gets triggered for the Broken one.
 
 function! Working()
   try
 let y = x
 return y
   catch /^Vim\%((\a\+)\)\=:E121/
  Handle 'Undefined variable' errors
 return 42
   endtry
 endfunction
 
 function! Broken()
   try
 return x
   catch /^Vim\%((\a\+)\)\=:E121/
  Handle 'Undefined variable' errors
 return 42
   endtry
 endfunction

I can reproduce it.  The pattern can be /E121/ to simplify the problem.

-- 
Over the years, I've developed my sense of deja vu so acutely that now
I can remember things that *have* happened before ...

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\download, build and distribute -- http://www.A-A-P.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

--~--~-~--~~~---~--~~
You received this message from the vim_dev maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Bug in exception handling with :return

2008-09-14 Fir de Conversatie Matt Wozniski

These two functions ought to behave identically, but don't... For some
reason, the :catch never gets triggered for the Broken one.

function! Working()
  try
let y = x
return y
  catch /^Vim\%((\a\+)\)\=:E121/
 Handle 'Undefined variable' errors
return 42
  endtry
endfunction

function! Broken()
  try
return x
  catch /^Vim\%((\a\+)\)\=:E121/
 Handle 'Undefined variable' errors
return 42
  endtry
endfunction

~Matt

--~--~-~--~~~---~--~~
You received this message from the vim_dev maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---