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

Attempt to perform arithmetic on a nil value #814

Closed
AnthonyCalandra opened this issue Dec 29, 2023 · 5 comments · Fixed by #817
Closed

Attempt to perform arithmetic on a nil value #814

AnthonyCalandra opened this issue Dec 29, 2023 · 5 comments · Fixed by #817
Labels
bug Something isn't working

Comments

@AnthonyCalandra
Copy link

Problem

Scrolling through some files I get stopped with the following error message:

Error detected while processing CursorMoved Autocommands for "*":
Error executing lua callback: ...azyVim-data/lazy/indent-blankline.nvim/lua/ibl/hooks.lua:225: attempt to perform arithmetic on a nil value
stack traceback:
        ...azyVim-data/lazy/indent-blankline.nvim/lua/ibl/hooks.lua:225: in function 'fn'
        ...LazyVim-data/lazy/indent-blankline.nvim/lua/ibl/init.lua:304: in function 'refresh'
        ...LazyVim-data/lazy/indent-blankline.nvim/lua/ibl/init.lua:128: in function 'debounced_refresh'

        ...LazyVim-data/lazy/indent-blankline.nvim/lua/ibl/init.lua:144: in function 'debounced_refresh'

        ...Vim-data/lazy/indent-blankline.nvim/lua/ibl/autocmds.lua:27: in function <...Vim-data/lazy/indent-blankline.nvim/lua/ibl/autocmds.lua:26>

I suspect maybe the attempted fix here of another issue is the problem: #809

Let me know if there is anything I can do to help.
Thanks for the plugin :)

Steps to reproduce

Start nvim and open the file you wish to edit. Start scrolling until an error message appears.

Here's an example file I was editing that showed the problem:

// https://quuxplusone.github.io/blog/2018/08/11/the-auto-macro/

#pragma once

template <class L>
class AtScopeExit
{
    L& m_lambda;

public:
    AtScopeExit(L& action) : m_lambda(action) {}
    ~AtScopeExit()
    {
        m_lambda();
    }
};

#define TOKEN_PASTEx(x, y) x##y
#define TOKEN_PASTE(x, y)  TOKEN_PASTEx(x, y)

#define Auto_INTERNAL1(lname, aname, ...) \
    auto lname = [&]() { __VA_ARGS__; };  \
    AtScopeExit<decltype(lname)> aname(lname);

#define Auto_INTERNAL2(ctr, ...)                     \
    Auto_INTERNAL1(TOKEN_PASTE(Auto_func_, ctr),     \
                   TOKEN_PASTE(Auto_instance_, ctr), \
                   __VA_ARGS__)

#define AT_SCOPE_EXIT(...) Auto_INTERNAL2(__COUNTER__, __VA_ARGS__)

Line 21 is an example of a line that triggers the error for me.

Expected behavior

There are no errors.

Neovim version (nvim -v)

NVIM v0.9.2

@AnthonyCalandra AnthonyCalandra added the bug Something isn't working label Dec 29, 2023
@Danielkonge
Copy link
Contributor

Danielkonge commented Dec 30, 2023

This error seems similar to the error I noticed in #743 (comment), but I don't really see what the error on line 255 is, so I am not sure if it is caused by the same thing.

If you replace end_line:find "%S" - 1 with #end_line - 1 in hooks.lua do you still get the error? (Note: this will not be the correct fix, since it doesn't capture what we want, I am just unsure if this part is what is causing the error?)

@omani
Copy link

omani commented Dec 30, 2023

same issue for me. errors while scrolling through rust code.

@lukas-reineke
Copy link
Owner

Released a fix

sorry for the delay, had some time off, and then we had the earthquake and tsunami

@calebdw
Copy link

calebdw commented Jan 3, 2024

@lukas-reineke, I'm still getting a similar error:

Error detected while processing CursorMoved Autocommands for "*":
Error executing lua callback: ...l/share/nvim/lazy/indent-blankline.nvim/lua/ibl/init.lua:478: invalid key: virt_text_repeat_linebreak
stack traceback:
        [C]: in function 'nvim_buf_set_extmark'
        ...l/share/nvim/lazy/indent-blankline.nvim/lua/ibl/init.lua:478: in function 'refresh'
        ...l/share/nvim/lazy/indent-blankline.nvim/lua/ibl/init.lua:128: in function 'debounced_refresh'
        ...l/share/nvim/lazy/indent-blankline.nvim/lua/ibl/init.lua:144: in function 'debounced_refresh'
        ...are/nvim/lazy/indent-blankline.nvim/lua/ibl/autocmds.lua:27: in function <...are/nvim/lazy/indent-blankline.nvim/lua/ibl/autocmds.lua:26>

@Danielkonge
Copy link
Contributor

@lukas-reineke, I'm still getting a similar error:

Error detected while processing CursorMoved Autocommands for "*":
Error executing lua callback: ...l/share/nvim/lazy/indent-blankline.nvim/lua/ibl/init.lua:478: invalid key: virt_text_repeat_linebreak
stack traceback:
        [C]: in function 'nvim_buf_set_extmark'
        ...l/share/nvim/lazy/indent-blankline.nvim/lua/ibl/init.lua:478: in function 'refresh'
        ...l/share/nvim/lazy/indent-blankline.nvim/lua/ibl/init.lua:128: in function 'debounced_refresh'
        ...l/share/nvim/lazy/indent-blankline.nvim/lua/ibl/init.lua:144: in function 'debounced_refresh'
        ...are/nvim/lazy/indent-blankline.nvim/lua/ibl/autocmds.lua:27: in function <...are/nvim/lazy/indent-blankline.nvim/lua/ibl/autocmds.lua:26>

That's not a similar error, that is a the same as #813.

You need to either use stable (0.9.5 is the latest, but I think 0.9.4 and older also work) or a newer version of 0.10 (not much more than a week old).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants