[vim/vim] Vim9 script compilation error when compiled with -clipboard and without GUI (Issue #19160)

8 views
Skip to first unread message

Coacher

unread,
Jan 11, 2026, 6:17:00 PMJan 11
to vim/vim, Subscribed
Coacher created an issue (vim/vim#19160)

Steps to reproduce

  1. Create test.vim as shown below
  2. Run vim --clean -u test.vim via Vim with -clipboard and without GUI
  3. Observe compilation error on start

test.vim:

vim9script

export var register: string

export def StoreClipboardName()
    if !has('clipboard')
        register = ''
    else
        var names = split(&clipboard, ',')
        if index(names, 'unnamedplus') >= 0
            register = '+'
        elseif index(names, 'unnamed') >= 0
            register = '*'
        else
            register = ''
        endif
    endif
enddef

autocmd VimEnter * StoreClipboardName()

Expected behaviour

There is no compilation error, because the code is valid.

This behavior is observed when running vim --clean -u test.vim via Vim with +clipboard and with GUI, e.g. vimx.

Version of Vim

VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Jan 09 2026 00:00:00) Included patches: 1-2068

Environment

Operating System: Fedora Linux 43
KDE Plasma Version: 6.5.4
KDE Frameworks Version: 6.22.0
Qt Version: 6.10.1
Kernel Version: 6.18.4-200.fc43.x86_64 (64-bit)
Graphics Platform: Wayland

Terminal: Konsole-25.12.1
$TERM: xterm-256color
Shell: bash 5.3.0(1)-release

Logs and stack traces

vim --version where error is seen:

VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Jan 09 2026 00:00:00)
Included patches: 1-2068
Modified by <bugz...@redhat.com>
Compiled by <bugz...@redhat.com>
Huge version without GUI.  Features included (+) or not (-):
+acl
+arabic
+autocmd
+autochdir
-autoservername
-balloon_eval
+balloon_eval_term
-browse
++builtin_terms
+byte_offset
+channel
+cindent
+clientserver
-clipboard
+clipboard_provider
+cmdline_compl
+cmdline_hist
+cmdline_info
+comments
+conceal
+cryptv
+cscope
+cursorbind
+cursorshape
+dialog_con
+diff
+digraphs
-dnd
-ebcdic
+emacs_tags
+eval
+ex_extra
+extra_search
-farsi
+file_in_path
+find_in_path
+float
+folding
-footer
+fork()
+gettext
-hangul_input
+iconv
+insert_expand
+ipv6
+job
+jumplist
+keymap
+lambda
+langmap
+libcall
+linebreak
+lispindent
+listcmds
+localmap
+lua/dyn
+menu
+mksession
+modify_fname
+mouse
-mouseshape
+mouse_dec
+mouse_gpm
-mouse_jsbterm
+mouse_netterm
+mouse_sgr
-mouse_sysmouse
+mouse_urxvt
+mouse_xterm
+multi_byte
+multi_lang
-mzscheme
+netbeans_intg
+num64
+packages
+path_extra
+perl/dyn
+persistent_undo
+popupwin
+postscript
+printer
+profile
-python
+python3/dyn-stable
+quickfix
+reltime
+rightleft
+ruby/dyn
+scrollbind
+signs
+smartindent
+socketserver
+sodium
-sound
+spell
+startuptime
+statusline
-sun_workshop
+syntax
+tabpanel
+tag_binary
-tag_old_static
-tag_any_white
-tcl
+termguicolors
+terminal
+terminfo
+termresponse
+textobjects
+textprop
+timers
+title
-toolbar
+user_commands
+vartabs
+vertsplit
+vim9script
+viminfo
+virtualedit
+visual
+visualextra
+vreplace
-wayland
-wayland_clipboard
-wayland_focus_steal
+wildignore
+wildmenu
+windows
+writebackup
-X11
+xattr
-xfontset
-xim
-xpm
-xsmp
-xterm_clipboard
-xterm_save
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
 3rd user vimrc file: "~/.config/vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wno-complain-wrong-lang -Werror=format-security -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -std=c17 -DSYS_VIMRC_FILE=/etc/vimrc -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -Wl,--enable-new-dtags -Wl,-z,relro -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-z,now -Wl,--build-id=sha1 -Wl,-z,relro -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes -L/usr/local/lib -o vim -lm -lselinux -lncurses -lsodium -lacl -lattr -lgpm


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/19160@github.com>

Coacher

unread,
Jan 11, 2026, 6:19:59 PMJan 11
to vim/vim, Subscribed
Coacher left a comment (vim/vim#19160)

Error:

Error detected while compiling VimEnter Autocommands for "*"..function <SNR>1_StoreClipboardName:
line    7:
E1001: Variable not found: names


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/19160/3736294053@github.com>

Foxe Chen

unread,
Jan 12, 2026, 8:16:17 AMJan 12
to vim/vim, Subscribed
64-bitman left a comment (vim/vim#19160)

Seems to work fine for me, could you try the latest Vim version?


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/19160/3738499911@github.com>

Coacher

unread,
Jan 12, 2026, 9:48:03 AMJan 12
to vim/vim, Subscribed
Coacher left a comment (vim/vim#19160)

Seems to work fine for me, could you try the latest Vim version?

Yes, will try in a day or two.


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/19160/3738917696@github.com>

Christian Brabandt

unread,
Jan 13, 2026, 2:37:53 PMJan 13
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#19160)

could not reproduce it either on latest master, but also saw this issue with some older Vim version. Let's assume this is fixed, so closing.


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/19160/3746141488@github.com>

Christian Brabandt

unread,
Jan 13, 2026, 2:37:53 PMJan 13
to vim/vim, Subscribed

Closed #19160 as not planned.


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/19160/issue_event/22025812962@github.com>

Coacher

unread,
Jan 14, 2026, 1:23:59 AMJan 14
to vim/vim, Subscribed
Coacher left a comment (vim/vim#19160)

Seems to work fine for me, could you try the latest Vim version?

I have tested on ead1dda. The issue persists.


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/19160/3747983291@github.com>

Coacher

unread,
Jan 14, 2026, 1:24:23 AMJan 14
to vim/vim, Subscribed
Coacher left a comment (vim/vim#19160)

could not reproduce it either on latest master, but also saw this issue with some older Vim version. Let's assume this is fixed, so closing.

This is not fixed here on ead1dda. Could you please reopen?


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/19160/3747984905@github.com>

Coacher

unread,
Jan 14, 2026, 3:28:17 AMJan 14
to vim/vim, Subscribed
Coacher left a comment (vim/vim#19160)

I've tested it a bit more. Here is a minimal example that works on any build:

vim9script

def TestFunction()
    if !has('bugs')
        echo 'No bugs'
    else
        var a_variable = 0
        if a_variable > 0
            echo 'Positive'
        elseif a_variable < 0
            echo 'Negative'
        else
            echo 'Zero'
        endif
    endif
enddef

defcompile

I've replaced check for 'clipboard' feature with an obviously missing feature. The issue then can be triggered on any build. I've also replaced all calls to other functions with simple echoes and assignments.

Surprisingly, replacing !has check with false allows to compile the function.

Also removing only elseif clause allows to compile the function.

Also saving the result of !has check to a variable before the outermost if clause allows to compile the function.


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/19160/3748391725@github.com>

Christian Brabandt

unread,
Jan 14, 2026, 6:16:10 AMJan 14
to vim/vim, Subscribed

Reopened #19160.


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/19160/issue_event/22040662315@github.com>

Christian Brabandt

unread,
Jan 14, 2026, 6:18:53 AMJan 14
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#19160)

looks a bit like this issue: #17750 ping @yegappan


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/19160/3749074662@github.com>

Christian Brabandt

unread,
12:31 PM (6 hours ago) 12:31 PM
to vim/vim, Subscribed

Closed #19160 as completed via f74a416.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/19160/issue_event/24685987732@github.com>

Reply all
Reply to author
Forward
0 new messages