Describe the bug
In Vim9 script, we cannot pass a list of numbers to cursor().
To Reproduce
Run this shell command:
vim -Nu NONE +'vim9 cursor([1, 1])'
E1210 is raised:
E1210: Number required for argument 2
Expected behavior
No error is raised, because :help cursor() states that cursor() accepts a single list as only argument. And it is allowed for the latter to only contain 2 numbers:
When there is one argument {list} this is used as a |List|
with two, three or four item:
[{lnum}, {col}]
Environment
Additional context
Regression introduced in 8.2.3188.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.![]()
Describe the bug
In Vim9 script, we cannot pass a list of numbers to
cursor().To Reproduce
Run this shell command:
vim -Nu NONE +'vim9 cursor([1, 1])'
E1210is raised:E1210: Number required for argument 2Expected behavior
No error is raised, because
:help cursor()states thatcursor()accepts a single list as only argument. And it is allowed for the latter to only contain 2 numbers:When there is one argument {list} this is used as a |List|
with two, three or four item:
[{lnum}, {col}]Environment
- Vim version: 8.2 Included patches: 1-3189
- OS: Ubuntu 20.04.2 LTS
- Terminal: XTerm(353)
Additional context
Regression introduced in 8.2.3188.
Fixed in 8.2.3194
—
You are receiving this because you commented.
This gives an error:
vim9script def Func() var prop: dict<any> = prop_find({type: 'TypeName'}) cursor(prop.lnum, prop.col) enddef defcompile
E1013: Argument 1: type mismatch, expected number but got any
Is it working as intended?
—
You are receiving this because you commented.
Is it working as intended?
There are 3 possibilities.
Vim gets smarter, and correctly infers that prop.lnum (as well as prop.col) is actually a number, even though it's included inside a dictionary of mixed values. I doubt that's possible without a lot of work though.
Vim accepts any at compile time, and waits until runtime to check whether prop.lnum is actually a number (it is). Pro: no error. Con: we might miss some errors at compile time.
Vim keeps rejecting any at compile time, and we need extra variables to feed the correct types to the compiler:
vim9script def Func() var prop: dict<any> = prop_find({type: 'TypeName'
})
var lnum: number = prop.lnum
var col: number = prop.col
cursor(lnum, col)
enddef
defcompile—
You are receiving this because you commented.
Something else looks weird. This gives an error:
vim9script def Func() var prop: dict<any> = prop_find({type: 'TypeName'
})
var lnum = prop.lnum
var col = prop.col
cursor(lnum, col)
enddef
defcompileE1013: Argument 1: type mismatch, expected number but got any
But not this:
vim9script def Func() var prop: dict<any> = prop_find({type: 'TypeName'}) var lnum: number =
prop.lnum
var col = prop.col
cursor(lnum, col)
enddef
defcompileWhy? To be consistent, a similar error should be given for the second argument of cursor():
E1013: Argument 2: type mismatch, expected number but got any
—
You are receiving this because you commented.
It looks like the recent patches have solved this problem.
—
You are receiving this because you commented.