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

Vim9: list slicing doesn't work in a ":def" function #6393

Closed
lacygoill opened this issue Jul 4, 2020 · 3 comments
Closed

Vim9: list slicing doesn't work in a ":def" function #6393

lacygoill opened this issue Jul 4, 2020 · 3 comments

Comments

@lacygoill
Copy link

Describe the bug

List slicing doesn't work in a :def function.

To Reproduce

Run this shell command:

vim -Nu NONE -S <(cat <<'EOF'
    vim9script
    def Func()
        echom ['aaa', 'bbb', 'ccc', 'ddd'][1]->string()
    enddef
    Func()
EOF
)

Vim prints this message:

''

Now, run this shell command:

vim -Nu NONE -S <(cat <<'EOF'
    vim9script
    def Func()
        echom ['aaa', 'bbb', 'ccc', 'ddd'][1:2]->string()
    enddef
    Func()
EOF
)

E111 is raised:

Error detected while processing function <SNR>1_Func:
line    1:
E111: Missing ']'

Expected behavior

In the first command, Vim prints this message:

'bbb'

In the second command, no error is raised, and Vim prints this message:

['bbb', 'ccc']

Environment

  • Vim version: 8.2 Included patches: 1-1127
  • OS: Ubuntu 16.04.6 LTS
  • Terminal: XTerm(356)

Additional context

List slicing works as expected in a Vim9 script, provided it's used outside a :def function:

vim -Nu NONE -S <(cat <<'EOF'
    vim9script
    echom ['aaa', 'bbb', 'ccc', 'ddd'][1]->string()
EOF
)

" correctly outputs:  'bbb'

vim -Nu NONE -S <(cat <<'EOF'
    vim9script
    echom ['aaa', 'bbb', 'ccc', 'ddd'][1:2]->string()
EOF
)

" correctly outputs:  ['bbb', 'ccc']
@lacygoill
Copy link
Author

The first example has been fixed, but not the second one:

vim -Nu NONE -S <(cat <<'EOF'
    vim9script
    def Func()
        echom ['aaa', 'bbb', 'ccc', 'ddd'][1:2]->string()
    enddef
    Func()
EOF
)

That is, we can get one member from a list with something like [123], but not an arbitrary sublist with possibly several members with something like [12:34].

@brammool
Copy link
Contributor

brammool commented Jul 5, 2020

List slicing hasn't been implemented yet.

@lacygoill
Copy link
Author

Ah ok, I thought it was a regression, because it worked as expected up to f93c7fe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants