mirror of
https://github.com/vim/vim
synced 2025-05-02 22:37:47 +02:00
Some checks are pending
GitHub CI / linux (i386, gcc, normal, ./src/shadow) (push) Waiting to run
GitHub CI / linux (native, clang, [], normal) (push) Waiting to run
GitHub CI / linux (native, clang, [], tiny) (push) Waiting to run
GitHub CI / linux (native, clang, true, [], huge, dynamic, stable-abi) (push) Waiting to run
GitHub CI / linux (native, gcc, [], normal) (push) Waiting to run
GitHub CI / linux (native, gcc, [], tiny) (push) Waiting to run
GitHub CI / linux (native, gcc, true, [], huge) (push) Waiting to run
GitHub CI / linux (arm64, gcc, [nogui], tiny) (push) Waiting to run
GitHub CI / linux (arm64, gcc, true, [unittests], huge) (push) Waiting to run
GitHub CI / linux (clang, [asan], huge, 5.1) (push) Waiting to run
GitHub CI / linux (clang, [nogui], tiny) (push) Waiting to run
GitHub CI / linux (gcc, [nogui], tiny) (push) Waiting to run
GitHub CI / linux (gcc, [vimtags], normal) (push) Waiting to run
GitHub CI / linux (gcc, true, [uchar testgui], huge, dynamic) (push) Waiting to run
GitHub CI / linux (gcc, true, [unittests], huge) (push) Waiting to run
GitHub CI / macos (huge, macos-13) (push) Waiting to run
GitHub CI / macos (huge, macos-15) (push) Waiting to run
GitHub CI / macos (normal, macos-13) (push) Waiting to run
GitHub CI / macos (normal, macos-15) (push) Waiting to run
GitHub CI / macos (tiny, macos-13) (push) Waiting to run
GitHub CI / macos (tiny, macos-15) (push) Waiting to run
GitHub CI / windows (no, no, x64, HUGE, stable, msvc) (push) Waiting to run
GitHub CI / windows (no, no, x86, TINY, mingw) (push) Waiting to run
GitHub CI / windows (no, yes, x64, yes, HUGE, mingw) (push) Waiting to run
GitHub CI / windows (no, yes, x86, NORMAL, msvc) (push) Waiting to run
GitHub CI / windows (yes, no, x64, NORMAL, mingw) (push) Waiting to run
GitHub CI / windows (yes, no, x86, HUGE, msvc) (push) Waiting to run
GitHub CI / windows (yes, yes, x64, TINY, msvc) (push) Waiting to run
GitHub CI / windows (yes, yes, x86, yes, HUGE, stable, mingw) (push) Waiting to run
CodeQL / Analyze (push) Waiting to run
Tuples were introduced in commit 9cb865e
. See PR #16776.
fixes: #16965
closes: #16935
Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
162 lines
3.1 KiB
VimL
162 lines
3.1 KiB
VimL
vim9script
|
|
# VIM_TEST_SETUP hi link vim9LambdaOperator Todo
|
|
# VIM_TEST_SETUP hi link vim9LambdaParen Todo
|
|
|
|
|
|
# Vim 9 lambda expressions
|
|
|
|
var Foo: func
|
|
var expr = 0
|
|
|
|
# without return type
|
|
|
|
Foo = () => expr
|
|
Foo = (_) => expr
|
|
Foo = (x) => expr
|
|
|
|
Foo = (...y) => expr
|
|
Foo = (_, ...y) => expr
|
|
Foo = (x, ...y) => expr
|
|
|
|
Foo = (x, y) => expr
|
|
|
|
Foo = (_: number) => expr
|
|
Foo = (x: number) => expr
|
|
|
|
Foo = (...y: list<number>) => expr
|
|
Foo = (_: number, ...y: list<number>) => expr
|
|
Foo = (x: number, ...y: list<number>) => expr
|
|
|
|
Foo = (x: number, y: number) => expr
|
|
|
|
# with return type
|
|
|
|
Foo = (): number => expr
|
|
Foo = (_): number => expr
|
|
Foo = (x): number => expr
|
|
|
|
Foo = (...y): number => expr
|
|
Foo = (_, ...y): number => expr
|
|
Foo = (x, ...y): number => expr
|
|
|
|
Foo = (x, y): number => expr
|
|
|
|
Foo = (_: number): number => expr
|
|
Foo = (x: number): number => expr
|
|
|
|
Foo = (...y: list<number>): number => expr
|
|
Foo = (_: number, ...y: list<number>): number => expr
|
|
Foo = (x: number, ...y: list<number>): number => expr
|
|
|
|
Foo = (x: number, y: number): number => expr
|
|
|
|
# with compound return type
|
|
|
|
Foo = (): list<number> => expr
|
|
Foo = (_): list<number> => expr
|
|
Foo = (x): list<number> => expr
|
|
|
|
Foo = (...y): list<number> => expr
|
|
Foo = (_, ...y): list<number> => expr
|
|
Foo = (x, ...y): list<number> => expr
|
|
|
|
Foo = (x, y): list<number> => expr
|
|
|
|
Foo = (_: number): list<number> => expr
|
|
Foo = (x: number): list<number> => expr
|
|
|
|
Foo = (...y: list<number>): list<number> => expr
|
|
Foo = (_: number, ...y: list<number>): list<number> => expr
|
|
Foo = (x: number, ...y: list<number>): list<number> => expr
|
|
|
|
Foo = (x: number, y: number): list<number> => expr
|
|
|
|
|
|
# post operator comments
|
|
|
|
Foo = () => # comment
|
|
expr
|
|
Foo = () =>
|
|
# comment
|
|
expr
|
|
Foo = () =>
|
|
|
|
# comment
|
|
|
|
expr
|
|
|
|
|
|
# line continuations
|
|
|
|
Foo = (x: string,
|
|
\ y: number,
|
|
\ z: bool) => expr
|
|
|
|
Foo = (x: string,
|
|
\ y: number,
|
|
\ z: bool)
|
|
\ => expr
|
|
|
|
Foo = (x: string,
|
|
\ y: number,
|
|
\ z: bool): number => expr
|
|
|
|
Foo = (x: string,
|
|
\ y: number,
|
|
\ z: bool): number
|
|
\ => expr
|
|
|
|
Foo = (x: string,
|
|
\ y: number,
|
|
\ z: bool):
|
|
\ number => expr
|
|
|
|
|
|
# funcref call
|
|
|
|
echo (() => 42)()
|
|
echo ((x: string): number => 42)("foo")
|
|
|
|
|
|
# :help vim9-lambda
|
|
|
|
var list = [1, 2, 3]
|
|
echo filter(list, (k, v) =>
|
|
v > 0)
|
|
echo filter(list, (k,
|
|
\ v)
|
|
\ => v > 0)
|
|
|
|
var Callback = (..._) => 'anything'
|
|
echo Callback(1, 2, 3) # displays "anything"
|
|
|
|
var Lambda = (arg) => {
|
|
g:was_called = 'yes'
|
|
return expr
|
|
}
|
|
|
|
var count = 0
|
|
var timer = timer_start(500, (_) => {
|
|
count += 1
|
|
echom 'Handler called ' .. count
|
|
}, {repeat: 3})
|
|
|
|
var dict = {}
|
|
var d = mapnew(dict, (k, v): string => {
|
|
return 'value'
|
|
})
|
|
|
|
|
|
# Issue #15970 (vim9: Restore and extend the recognition of Enum body items)
|
|
|
|
def Op(): func(func(number, number): number): func(number, Digit): number
|
|
return (F: func(number, number): number) =>
|
|
(x: number, y: Digit): number => F(x, y.value)
|
|
enddef ####################### ^ vimCommand?
|
|
|
|
|
|
# Issue #16965 (vim syntax: wrong highlight with lambda, autoload, and false keyword)
|
|
|
|
autocmd BufRead * timer_start(0, (_) => f#a(false, false))
|
|
autocmd
|
|
|