[vim/vim] Fix Vim9 read-only register assignment compilation (PR #18806)

12 views
Skip to first unread message

dkearns

unread,
Nov 25, 2025, 6:15:04 AM (5 days ago) Nov 25
to vim/vim, Subscribed

Problem: Assignment to read-only registers @: and @% is allowed during
compilation.
Solution: Abort compilation and emit an E354 error when assigning to
these registers.

Fix the E354 error emitted when attempting to declare @: with :var so
that it references the correct register, @:, rather than the garbage
string "^@".


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/18806

Commit Summary

  • 8e87667 Fix Vim9 read-only register assignment compilation

File Changes

(3 files)

Patch Links:


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

Yegappan Lakshmanan

unread,
Nov 28, 2025, 11:03:08 AM (yesterday) Nov 28
to vim/vim, Subscribed

@yegappan approved this pull request.


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/pull/18806/review/3519441712@github.com>

Yegappan Lakshmanan

unread,
Nov 28, 2025, 11:05:00 AM (yesterday) Nov 28
to vim/vim, Subscribed

@yegappan commented on this pull request.


In src/testdir/test_vim9_assign.vim:

> @@ -1592,12 +1592,21 @@ def Test_assignment_failure()
   v9.CheckDefFailure(['var $VAR = 5'], 'E1016: Cannot declare an environment variable:')
   v9.CheckScriptFailure(['vim9script', 'var $ENV = "xxx"'], 'E1016:')
 
+  # read-only registers
+  v9.CheckDefFailure(['var @. = 5'], 'E354:', 1)
+  v9.CheckDefFailure(['var @% = 5'], 'E354:', 1)
+  v9.CheckDefFailure(['var @: = 5'], 'E354:', 1)
+  v9.CheckScriptFailure(['vim9script', 'var @. = 5'], 'E1066:', 2)
+  v9.CheckScriptFailure(['vim9script', 'var @% = 5'], 'E1066:', 2)
+  v9.CheckScriptFailure(['vim9script', 'var @: = 5'], 'E1066:', 2)

Instead of using CheckDefFailure() and then CheckScriptFailure() for the same test, can you use the CheckDefAndScriptFailure() function instead?


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/pull/18806/review/3519445936@github.com>

dkearns

unread,
Nov 28, 2025, 10:55:28 PM (23 hours ago) Nov 28
to vim/vim, Push

@dkearns pushed 1 commit.

  • df462a2 Fix Vim9 read-only register assignment compilation


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18806/before/8e87667a181935cab66123ee82fe1fa1bf664865/after/df462a2a04e717dae72a8a3a693e1c116f53846b@github.com>

dkearns

unread,
Nov 28, 2025, 10:58:42 PM (23 hours ago) Nov 28
to vim/vim, Subscribed

@dkearns commented on this pull request.


In src/testdir/test_vim9_assign.vim:

> @@ -1592,12 +1592,21 @@ def Test_assignment_failure()
   v9.CheckDefFailure(['var $VAR = 5'], 'E1016: Cannot declare an environment variable:')
   v9.CheckScriptFailure(['vim9script', 'var $ENV = "xxx"'], 'E1016:')
 
+  # read-only registers
+  v9.CheckDefFailure(['var @. = 5'], 'E354:', 1)
+  v9.CheckDefFailure(['var @% = 5'], 'E354:', 1)
+  v9.CheckDefFailure(['var @: = 5'], 'E354:', 1)
+  v9.CheckScriptFailure(['vim9script', 'var @. = 5'], 'E1066:', 2)
+  v9.CheckScriptFailure(['vim9script', 'var @% = 5'], 'E1066:', 2)
+  v9.CheckScriptFailure(['vim9script', 'var @: = 5'], 'E1066:', 2)

Done.

I was just matching the local use of the Check* functions there. I'll also do a separate pass to update that file and others to use v9.CheckDefAndScriptFailure as I prefer to keep these bug fix commits as tight as possible.

Thanks for looking it over.


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/pull/18806/review/3520461158@github.com>

Reply all
Reply to author
Forward
0 new messages