[vim/vim] Vim9: misleading word in error message given when using multiple iteration variables (Issue #10435)

7 views
Skip to first unread message

lacygoill

unread,
May 16, 2022, 2:21:59 PM5/16/22
to vim/vim, Subscribed

Steps to reproduce

Run this shell command:

vim -Nu NONE -S <(tee <<'EOF'
    vim9script
    def Func()
        for [a: number, b: job] in [[0, '']]
        endfor
    enddef
    Func()
EOF
)

This error is given:

E1013: Argument 2: type mismatch, expected job but got string
       ^------^

Notice how Vim refers to the b iteration variable as an argument.

Expected behavior

This error is given:

E1013: Variable 2: type mismatch, expected job but got string
       ^------^

Notice how this time Vim refers to the b iteration variable as a variable.

Version of Vim

8.2 Included patches: 1-4960

Environment

Operating system: Ubuntu 20.04.4 LTS
Terminal: xterm
Value of $TERM: xterm-256color
Shell: GNU bash, version 5.0.17

Additional context

The syntax which lets us iterate over multiple variables is documented below :help E1140:

:for [{var1}, {var2}, ...] in {listlist}
:endfo[r]                                                       *E1140*
                        Like `:for` above, but each item in {listlist} must be
                        a list, of which each item is assigned to {var1},
                        {var2}, etc.  Example: >
                                :for [lnum, col] in [[1, 3], [2, 5], [3, 8]]
                                   :echo getline(lnum)[col]
                                :endfor

At no point is the word "argument" ever used. The identifiers which are used to iterate over the values are referred to as "var1", "var2", ... which are shorthands for "variable 1", "variable 2", ...


When unpacking a list, if an error must be given, Vim correctly uses the word "Variable", and not "Argument":

vim9script
def Func()
    var a: number
    var b: job
    [a, b] = [0, '']
enddef
Func()
E1163: Variable 2: type mismatch, expected job but got string
       ^------^


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/10435@github.com>

Bram Moolenaar

unread,
May 17, 2022, 11:13:30 AM5/17/22
to vim/vim, Subscribed

Closed #10435 via bd3a9d2.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/10435/issue_event/6625417339@github.com>

Reply all
Reply to author
Forward
0 new messages