[vim/vim] Vim9Script fails to parse multi-line dictionary inside a lambda (Issue #20693)

1 view
Skip to first unread message

BenYip

unread,
Jul 2, 2026, 11:01:52 PM (5 hours ago) Jul 2
to vim/vim, Subscribed
bennyyip created an issue (vim/vim#20693)

Steps to reproduce

  1. create foo.vim
vim9script

timer_start(0, (_) => {
  const d = {
    'foo': {'bar': 'baz'}
  }
})
  1. vim --clean foo.vim
  2. :source %

Expected behaviour

The script runs without error.

Version of Vim

9.2.0780

Environment

https://github.com/vim/vim-win32-installer/releases/download/v9.2.0780/gvim_9.2.0780_x64.exe

Logs and stack traces

Error detected while compiling C:/Users/bennyyip/foo.vim[6]..function <lambda>81:
line    2:
E723: Missing end of Dictionary '}': [end of lines]
Error detected while processing C:/Users/bennyyip/foo.vim:
line    7:
E116: Invalid arguments for function timer_start(0, (_) => {


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20693@github.com>

Mao-Yining

unread,
1:25 AM (2 hours ago) 1:25 AM
to vim/vim, Subscribed
mao-yining left a comment (vim/vim#20693)
vim9script

timer_start(0, (_) => {
  const d = {
    'foo': {'bar': 'baz'}}
})


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20693/4872859207@github.com>

Mao-Yining

unread,
1:28 AM (2 hours ago) 1:28 AM
to vim/vim, Subscribed
mao-yining left a comment (vim/vim#20693)
						*command-block* *E1026*
定义用户命令时也可用代码块。在代码块内使用 Vim9 语法。

这里是个使用嵌入文档 (here-docs) 的例子: >
    com SomeCommand {
        g:someVar =<< trim eval END
          ccc
          ddd
        END
      }

如果语句包含字典,其结束花括号不能写在行首。否则,被解析为代码块的结束。下面这
样不行: >
	command NewCommand {
	     g:mydict = {
	       'key': 'value',
	       }  # 错误: 会识别为代码块的结束
	   }
把 '}' 放在最后项目之后可以解决这个问题: >
	command NewCommand {
	     g:mydict = {
	       'key': 'value' }
	   }

理据: "}" 不能在命令之后出现,因为需要对命令进行解析才能找到它。为了一致起见,
"{" 之后也不能跟随命令。不幸的是,这就意味着不接受 "() => {  command  }",必须
使用换行。

							*vim9-curly*
为了不让字典常量的 "{" 被识别为语句块,把它包围在括号里: >
	var Lambda = (arg) => ({key: 42})

和命令块的开始有歧义的话也是如此: >
	({
	    key: value
	 })->method()

>


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20693/4872869900@github.com>

BenYip

unread,
2:26 AM (1 hour ago) 2:26 AM
to vim/vim, Subscribed
bennyyip left a comment (vim/vim#20693)

But this is a lambda, not a command block.

Rationale: The "}" cannot be after a command because it would require parsing
the commands to find it. For consistency with that no command can follow the
"{". Unfortunately this means using "() => { command }" does not work, line
breaks are always required.

The lambda body should be parsed, right?


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20693/4873169389@github.com>

Mao-Yining

unread,
2:33 AM (1 hour ago) 2:33 AM
to vim/vim, Subscribed
mao-yining left a comment (vim/vim#20693)

The lambda body should be parsed, right?

I hope so too, but I suspect the answer isn't optimistic.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20693/4873230046@github.com>

Maxim Kim

unread,
3:06 AM (1 hour ago) 3:06 AM
to vim/vim, Subscribed
habamax left a comment (vim/vim#20693)

I would love this to be fixed as well, if it is possible.
I always forget where to put the ending }.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20693/4873582814@github.com>

Mao-Yining

unread,
3:11 AM (28 minutes ago) 3:11 AM
to vim/vim, Subscribed
mao-yining left a comment (vim/vim#20693)

This is a duplicate issue. Ref: #9352. @bennyyip I think you may should close this issue.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20693/4873642383@github.com>

Reply all
Reply to author
Forward
0 new messages