New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid Vim's bug of :return in try-catch #565
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🍣
f9572be
to
565910d
Compare
一応もう1人ぐらいレビューしていただいたらマージします |
ありがとうございます!正確には問題になるのは例外ではなく Vim のエラーです。 function! s:throw(msg) abort
throw a:msg
endfunction
function! s:test() abort
try
return s:throw('foo')
catch
return 'ok'
endtry
endfunction
echo s:test()
" => ok 呼び出した先でのエラーも大丈夫(内部構造理解してないですが、たぶん例外に変換されている?)。 function! s:throw() abort
let _ = [] == 0
endfunction
function! s:test() abort
try
return s:throw()
catch
return 'ok'
endtry
endfunction
echo s:test()
" => ok |
という点を踏まえた上でも対策はしておいた方が安全かな…? |
すみません,どういうエラーが飛んでくるかまでは考慮せず問題が起こりそうな箇所はすべて回避するコードを入れている状態です.確認したほうが良いでしょうか |
|
あと既存のグローバル関数名と被った時エラーにならないように |
あっ…すみません。コメント読んでませんでした…orz |
Vim script の
:return {expr}
の{expr}
で例外が飛んでも:catch
で補足されないようです.回避する修正を入れました.