vim9script variable is garbage collected when it shouldn't be?

6 views
Skip to first unread message

Christian J. Robinson

unread,
Mar 5, 2025, 1:52:28 PM3/5/25
to vim_dev
 Foo.vim:

    vim9script

    export class Foo
        def new()
        enddef
        def Bar(s: string)
            echo $"{s} works"
        enddef
    endclass

vim9_regression.vim:

    vim9script

    if get(g:, 'did_foo', false)
        finish
    endif

    g:did_foo = true

    import autoload './Foo.vim'

    var foo = Foo.Foo.new()

    command -buffer -bar -nargs=1 Foo foo.Bar(<f-args>)


Source vim9_regression.vim, and run ":Foo bar" and you'll get the expected "bar works" message, but source vim9_regression.vim again you'll get:
E121: Undefined variable: foo


--
Christian J. Robinson <hep...@gmail.com>

Heptite

unread,
Mar 5, 2025, 1:55:07 PM3/5/25
to vim_dev
Sorry for the noise, I realized I need to add "noclear" to the vim9script command.
Reply all
Reply to author
Forward
0 new messages