Loading ...
Sorry, an error occurred while loading the content.

[BUG] try .. catch does not work in a for loop for a «E15 in false if» bug

Expand Messages
  • ZyX
    Consider the following code: % cat test-filereadable.vim
    Message 1 of 1 , Jan 25, 2011
    • 0 Attachment
      Consider the following code:

      % cat > test-filereadable.vim <<EOF
      set nocompatible
      let s:g={"load":{"saveoptions":{"abc":function("string")}}}
      function TestFileReadable()
      let file="/non-existent-file"
      let tail="abc"
      try
      if filereadable(file)
      call s:g.load.saveoptions[tail](readfile(file, 'b'))
      endif
      catch /^Vim(call):E15:/
      endtry
      endfunction
      function TestFileReadable2()
      for file in ["/non-existent-file"]
      let tail="abc"
      try
      if filereadable(file)
      call s:g.load.saveoptions[tail](readfile(file, 'b'))
      endif
      catch /^Vim(call):E15:/
      endtry
      endfor
      endfunction
      try
      call TestFileReadable()
      catch
      call writefile([v:exception], "bad")
      endtry
      try
      call TestFileReadable2()
      catch
      call writefile([v:exception], "bad2")
      endtry
      qa!
      EOF
      % vim -u NONE -S test-filereadable.vim

      It has just the same code as script in previous bug, but with `try .. catch' and
      a `for' loop. Note that first exception is successfully caught, but second is
      not. Tested on vim-7.3.102 and on vim-7.3.107 from mercurial repository.
    Your message has been successfully submitted and would be delivered to recipients shortly.