junegunn / junegunn/vader.vim

Got 'Undefined variable: sam' when using `g:vader_exception` right after `AssertThrows`

Open
#160 6 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Vim Script
Stars
599
Forks
40
PR merge metrics
No merged PRs in 30d

Description

Hi folks.
I got this suspicious bug when doing a test. When I passed a variable `sam` defined within an `Execute` block to a function and tested the call with an `AssertThrows` and then wanted to verify the throw with `g:vader_exception`, Vader/Vim gave this error:
```vader
(2/2) [EXECUTE] Undefined sam
> Vim(call):E121: Undefined variable: sam
```
Here is a minimal example that repeats the situation:
```vader
Execute(Undefined sam):
function! F(x)
throw 'Hello'
endfunction

let sam = {}
AssertThrows call F(sam)
Log g:vader_exception
```
The variable `g:vader_throwpoint` also subjects to this bug.
```vader
Execute(Undefined sam):
function! F(x)
throw 'Hello'
endfunction

let sam = {}
AssertThrows call F(sam)
Log g:vader_throwpoint
```
shows:
```
(1/1) [EXECUTE] Undefined sam
> function vader#assert#throws, line 5
```

Have I been using the ``AssertThrows`` tool in the wrong way? Note, even if the throwing function is autoloaded, the bug is still here.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.