function! ERB()
execute "try"
\."\n echo tr()"
\."\n catch"
\."\n echomsg v:exception"
\."\n return 1"
\."\n endtry"
\."\n return 0"
return r
endfunction
echomsg ERB()
execute "try"
\."\n call tr()"
\."\n catch"
\."\n echomsg v:exception"
\."\n endtry"
(also attached). If you source it with `vim -u NONE -N -S execute-return-bug.vim` you will see
Vim(echo):E119: Not enough arguments for function: tr
0
Error detected while processing /home/zyx/tmp/vim/execute-return-bug.vim:
line 16:
E119: Not enough arguments for function: tr
while expected to see
Vim(echo):E119: Not enough arguments for function: tr
1
Vim(call):E119: Not enough arguments for function: tr
(note the second line: it contains 1; and the third: it shows caught exception). If I unwrap the script (replace `:execute` calls with the string it executes) then everything works as expected.