Skip to content
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

Fix: assert_fails doesn't work properly in try block #4639

Closed
wants to merge 3 commits into from

Conversation

Projects
None yet
1 participant
@ichizok
Copy link

commented Jul 10, 2019

Problem (reported by @bmtsstl)

In try block, assert_fails(cmd) cannot handle the user-exception thrown from "cmd".

test.vim

try
  call assert_fails('throw "error"')
endtry
vim --clean

:so test.vim
Error detected while processing /path/to/test.vim:
line    2:
E605: Exception not caught: error

:echo v:errors
['/path/to/test.vim line 2: command did not fail: throw "error"']

Expected: No error shown (i.e. assert_fails() succeeds)

:so test.vim
:echo v:errors
[]

Cause

In try block (trylevel > 0) the user-exception is handled after evaluating the line of assert_fails(cmd).
https://github.com/vim/vim/blob/master/src/ex_docmd.c#L1247

Solution

I think should reset trylevel in assert_fails().

@brammool brammool closed this in 7780e5c Jul 10, 2019

@ichizok ichizok deleted the ichizok:fix/try-assert_fails branch Jul 10, 2019

blueyed added a commit to blueyed/neovim that referenced this pull request Jul 11, 2019

vim-patch:8.1.1660: assert_fails() does not fail inside try/catch
Problem:    Assert_fails() does not fail inside try/catch.
Solution:   Set trylevel to zero. (Ozaki Kiichi, closes vim/vim#4639)
vim/vim@7780e5c

blueyed added a commit to blueyed/neovim that referenced this pull request Jul 11, 2019

vim-patch:8.1.1660: assert_fails() does not fail inside try/catch
Problem:    Assert_fails() does not fail inside try/catch.
Solution:   Set trylevel to zero. (Ozaki Kiichi, closes vim/vim#4639)
vim/vim@7780e5c

justinmk added a commit to neovim/neovim that referenced this pull request Jul 12, 2019

vim-patch:8.1.1660: assert_fails() inside try/catch #10472
Problem:    Assert_fails() does not fail inside try/catch.
Solution:   Set trylevel to zero. (Ozaki Kiichi, closes vim/vim#4639)
vim/vim@7780e5c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.