Skip to content

Commit 2447131

Browse files
dkearnschrisbra
authored andcommitted
patch 9.1.1923: wrong error when assigning to read-only register
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 76b92b2 (tag: v7.0b). closes: #18757 Signed-off-by: Doug Kearns <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent ea86e53 commit 2447131

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

src/evalvars.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,8 +1088,6 @@ ex_let(exarg_T *eap)
10881088
argend = skip_var_list(arg, TRUE, &var_count, &semicolon, FALSE);
10891089
if (argend == NULL)
10901090
return;
1091-
if (argend > arg && argend[-1] == '.') // for var.='str'
1092-
--argend;
10931091
expr = skipwhite(argend);
10941092
concat = expr[0] == '.'
10951093
&& ((expr[1] == '=' && in_old_script(2))

src/testdir/test_registers.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,4 +1260,11 @@ func Test_insert_small_delete_linewise()
12601260
bwipe!
12611261
endfunc
12621262

1263+
func Test_writing_readonly_regs()
1264+
call assert_fails('let @. = "foo"', 'E354:')
1265+
call assert_fails('let @% = "foo"', 'E354:')
1266+
call assert_fails('let @: = "foo"', 'E354:')
1267+
call assert_fails('let @~ = "foo"', 'E354:')
1268+
endfunc
1269+
12631270
" vim: shiftwidth=2 sts=2 expandtab

src/testdir/test_vim9_expr.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3352,7 +3352,7 @@ def Test_expr9_register()
33523352
END
33533353
v9.CheckDefAndScriptSuccess(lines)
33543354

3355-
v9.CheckDefAndScriptFailure(["@. = 'yes'"], ['E354:', 'E488:'], 1)
3355+
v9.CheckDefAndScriptFailure(["@. = 'yes'"], 'E354:', 1)
33563356
enddef
33573357

33583358
" This is slow when run under valgrind.

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,8 @@ static char *(features[]) =
729729

730730
static int included_patches[] =
731731
{ /* Add new patch number below this line */
732+
/**/
733+
1923,
732734
/**/
733735
1922,
734736
/**/

0 commit comments

Comments
 (0)