vim-patch:9.1.1923: wrong error when assigning to read-only register (#36644)

Problem:  When assigning to @. in a :let command an incorrect "E15"
          error is emitted.
Solution: Emit the correct "E354" error. (Doug Kearns).

An incorrect "E488" error was also emitted in Vim9 script assignments.

It appears that the code deleted in this commit was added to work around
a limitation in the returned value from find_name_end() that no longer
exists.

See commit 76b92b2830841fd4e05006cc3cad1d8f0bc8101b (tag: v7.0b).

closes: vim/vim#18757

2447131e00

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
This commit is contained in:
zeertzjq
2025-11-21 08:24:00 +08:00
committed by GitHub
parent 1eec08d1a2
commit 30a09bdd7e
2 changed files with 7 additions and 3 deletions

View File

@@ -915,9 +915,6 @@ void ex_let(exarg_T *eap)
if (argend == NULL) { if (argend == NULL) {
return; return;
} }
if (argend > arg && argend[-1] == '.') { // For var.='str'.
argend--;
}
expr = skipwhite(argend); expr = skipwhite(argend);
bool concat = strncmp(expr, "..=", 3) == 0; bool concat = strncmp(expr, "..=", 3) == 0;
bool has_assign = *expr == '=' || (vim_strchr("+-*/%.", (uint8_t)(*expr)) != NULL bool has_assign = *expr == '=' || (vim_strchr("+-*/%.", (uint8_t)(*expr)) != NULL

View File

@@ -1146,4 +1146,11 @@ func Test_insert_small_delete_linewise()
bwipe! bwipe!
endfunc endfunc
func Test_writing_readonly_regs()
call assert_fails('let @. = "foo"', 'E354:')
call assert_fails('let @% = "foo"', 'E354:')
call assert_fails('let @: = "foo"', 'E354:')
call assert_fails('let @~ = "foo"', 'E354:')
endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab