Describe the bug
In Vim9 script, the execution does not stop when we set a breakpoint with :breakadd expr, and expr is assigned from a :def function.
To Reproduce
Run this shell command:
vim -Nu NONE -S <(cat <<'EOF'
vim9script
g:curfile = ''
breakadd expr g:curfile
def Func()
g:curfile = @%
eval 1 + 0
enddef
autocmd BufEnter * Func()
edit foo
edit bar
EOF
)
The execution doesn't stop.
Expected behavior
The execution does stop when the value of g:curfile changes from foo to bar.
Environment
Additional context
No issue when Func() is re-written as a legacy function:
vim9script g:curfile = '' breakadd expr g:curfile function Func() let g:curfile = @% eval 1 + 0 endfunction autocmd BufEnter * Func() edit foo edit bar
I suspect that there are other issues with :breakadd expr, not necessarily related to Vim9. But it's hard to be sure how the command is supposed to work, because there are no examples and no tests. It was introduced in the patch 8.0.0515.
I'll try to make more tests once this issue is fixed. If it can be made to work reliably, it should make debugging Vim scripts much faster.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
![]()
I suspect that there are other issues with :breakadd expr, not necessarily related to Vim9.
For example:
breakadd expr execute('ls!') =~ 'bar' function Func() edit bar
eval 1 + 0
endfunction
edit foo call Func()
Why doesn't Vim stop when Func() edits bar causing the output of ls! to match bar? Is it because the expression can only be a variable name?
And here:
breakadd expr Unknown() function FuncA() endfunction function FuncB() endfunction function FuncC() endfunction function
E117: Unknown function: Unknown
E117: Unknown function: Unknown
function FuncB()
function FuncC()
E117 is given which is expected; but why is it given twice? And why is FuncA() absent from the function table. It's still present if we remove :breakadd:
function FuncA() endfunction function FuncB() endfunction function FuncC() endfunction function
function FuncA()
function FuncB()
function FuncC()
In a Vim9 script, it's even worse. The whole table is cleared:
vim9script breakadd expr Unknown() function FuncA() endfunction function FuncB() endfunction function FuncC() endfunction function
E117: Unknown function: Unknown
And here:
vim9script breakadd expr execute('ls') =~ 'file' packadd netrw Explore
The execution stops and Vim prints this:
Oldval = "v:false"
Newval = "0"
One might expect that v:false and 0 are handled like the same value. Should/could they? Or are we meant to turn booleans into numbers with ? 1 : 0:
breakadd expr execute('ls') =~ 'file' ? 1 : 0
^------^
The execution stops and Vim prints this:
Oldval = "v:false" Newval = "0"
BTW, the v: prefix in front of v:false suggests that the expression is evaluated in the legacy context (in Vim9, it would have been dropped, just like in :vim9 echo v:false). But :breakadd expr is written in a Vim9 script. Shouldn't the expression be evaluated in the Vim9 context?
there are no examples
Actually, there is this example at :help :breakadd:
:breakadd expr g:lnum
But it's not enough to get answers for the previously mentioned questions.
A :def function needs to be compiled specifically for debugging. That currently only happens when a breakpoint was set in the function. When an expression breakpoint is set, all functions need to be compiled for debugging. It's inefficient, but there is no other way. I'll see if that can be made to work without too many changes.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub.