We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug
In Vim9 script, we can't use a subscript to get the n'th byte of a string inside a :def function.
:def
To Reproduce
Run this shell command:
vim -Nu NONE -S <(cat <<'EOF' vim9script def Func() let str = 'abc' echo str[1] enddef defcompile EOF )
E1090 is raised:
E1090
Error detected while processing function <SNR>1_Func: line 2: E1090: List, Dict or Blob required
Expected behavior
No error is raised. b is echo'ed.
b
Environment
Additional context
The issue disappears outside a :def function. Either at the script level:
vim9script let str = 'abc' echo str[1]
Or inside a legacy function:
vim9script fu Func() let str = 'abc' echo str[1] endfu Func()
Here are some other unexpected errors:
vim9script def Func() let l = [] let x = len(l) if l[0] endif enddef Func()
This code raises E684, which is expected:
E684
Error detected while processing function <SNR>1_Func: line 2: E684: list index out of range: 0
What is not expected is the address of the error line: 2. It matches this line:
2
let x = len(l)
While the error should come from the third line:
if l[0]
Similarly, consider this code:
vim9script def Func() let l = [] l = [''] if l[0][0] endif # a # b # c enddef Func()
It raises E714:
E714
Error detected while processing function <SNR>1_Func: line 7: E714: List required
Again, the address of the error line seems wrong. 7 matches this line:
7
# c
While the error is raised from the third line:
if l[0][0]
I had a look at the todo list, and the only items which may be relevant are:
vim/runtime/doc/todo.txt
Line 50 in a90afb9
Line 112 in a90afb9
The first one is about list slicing. But the current issue is about strings, not lists. Not sure whether the distinction matters for a possible fix.
I don't know what is the second one about.
The text was updated successfully, but these errors were encountered:
bf9d8c3
No branches or pull requests
Describe the bug
In Vim9 script, we can't use a subscript to get the n'th byte of a string inside a
:def
function.To Reproduce
Run this shell command:
E1090
is raised:Expected behavior
No error is raised.
b
is echo'ed.Environment
Additional context
The issue disappears outside a
:def
function. Either at the script level:Or inside a legacy function:
Here are some other unexpected errors:
This code raises
E684
, which is expected:What is not expected is the address of the error line:
2
. It matches this line:While the error should come from the third line:
Similarly, consider this code:
It raises
E714
:Again, the address of the error line seems wrong.
7
matches this line:While the error is raised from the third line:
I had a look at the todo list, and the only items which may be relevant are:
vim/runtime/doc/todo.txt
Line 50 in a90afb9
vim/runtime/doc/todo.txt
Line 112 in a90afb9
The first one is about list slicing. But the current issue is about strings, not lists. Not sure whether the distinction matters for a possible fix.
I don't know what is the second one about.
The text was updated successfully, but these errors were encountered: