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

test_override('defcompile', 1) gives lots of false errors #14969

Open
errael opened this issue Jun 12, 2024 · 3 comments
Open

test_override('defcompile', 1) gives lots of false errors #14969

errael opened this issue Jun 12, 2024 · 3 comments
Labels
bug vim9script Vim9 script related issues

Comments

@errael
Copy link
Contributor

errael commented Jun 12, 2024

Steps to reproduce

Source the given script and get.

Error detected while compiling /home/err/work/bugs/vim/defcompile/t.vim[7]..function <SNR>43_F1:
line    1:
E117: Unknown function: F2

But if the test_override statement is commented out, then the defcompile at the end gets no error. This is more in line with expected usage/behavior.

vim9script

test_override('defcompile', 1)

def F1()
    F2()
enddef

def F2()
enddef

defcompile

Expected behaviour

If, when test_override('defcompile', 1), defcompile is done at the end of the file this would be more in line with how things actually work.

@yegappan I took a look at code, but I couldn't even figure out where end of file happens.

Version of Vim

9.1.474

Environment

linux/gtk3

Logs and stack traces

No response

@errael errael added the bug label Jun 12, 2024
@zeertzjq zeertzjq added the vim9script Vim9 script related issues label Jun 12, 2024
@chrisbra
Copy link
Member

I think what happens, is that test_override('defcompile', 1) causes your function to be compiled immediately when it is defined. So in your case the definition of F2() isn't seen yet, so it errors out. That's why you put the :defcompile at the end :)

@errael
Copy link
Contributor Author

errael commented Jun 12, 2024

what happens, is that test_override('defcompile', 1) causes your function to be compiled immediately when it is defined

Right. I was able to find that in the code.

That's why you put the :defcompile at the end :)

Yes. Now if only test_override would do that too.

@chrisbra
Copy link
Member

Yes. Now if only test_override would do that too.

In that case, I guess we should make it try to compile whenever it reaches the end of a file. Not sure how easy this would be to be implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug vim9script Vim9 script related issues
Projects
None yet
Development

No branches or pull requests

3 participants