Patch 8.2.3376

4 views
Skip to first unread message

Bram Moolenaar

unread,
Aug 25, 2021, 4:38:22 PM8/25/21
to vim...@googlegroups.com

Patch 8.2.3376
Problem: Vim9: no warning that "@r" does not do anything.
Solution: Give a "no effect" error. (closes #8779)
Files: src/ex_eval.c, src/proto/ex_eval.pro, src/vim9compile.c,
src/testdir/test_vim9_cmd.vim


*** ../vim-8.2.3375/src/ex_eval.c 2021-08-10 19:52:57.470235546 +0200
--- src/ex_eval.c 2021-08-25 22:19:37.997589126 +0200
***************
*** 887,892 ****
--- 887,912 ----
}
}

+ int
+ cmd_is_name_only(char_u *arg)
+ {
+ char_u *p = arg;
+ char_u *alias;
+ int name_only = FALSE;
+
+ if (*p == '&')
+ {
+ ++p;
+ if (STRNCMP("l:", p, 2) == 0 || STRNCMP("g:", p, 2) == 0)
+ p += 2;
+ }
+ else if (*p == '@')
+ ++p;
+ get_name_len(&p, &alias, FALSE, FALSE);
+ name_only = ends_excmd2(arg, skipwhite(p));
+ vim_free(alias);
+ return name_only;
+ }

/*
* ":eval".
***************
*** 897,914 ****
typval_T tv;
evalarg_T evalarg;
int name_only = FALSE;
- char_u *p;
long lnum = SOURCING_LNUM;

if (in_vim9script())
! {
! char_u *alias;
!
! p = eap->arg;
! get_name_len(&p, &alias, FALSE, FALSE);
! name_only = ends_excmd2(eap->arg, skipwhite(p));
! vim_free(alias);
! }

fill_evalarg_from_eap(&evalarg, eap, eap->skip);

--- 917,926 ----
typval_T tv;
evalarg_T evalarg;
int name_only = FALSE;
long lnum = SOURCING_LNUM;

if (in_vim9script())
! name_only = cmd_is_name_only(eap->arg);

fill_evalarg_from_eap(&evalarg, eap, eap->skip);

*** ../vim-8.2.3375/src/proto/ex_eval.pro 2021-08-05 20:39:59.346053681 +0200
--- src/proto/ex_eval.pro 2021-08-25 22:19:41.133582344 +0200
***************
*** 12,17 ****
--- 12,18 ----
void discard_current_exception(void);
void catch_exception(except_T *excp);
void report_make_pending(int pending, void *value);
+ int cmd_is_name_only(char_u *arg);
void ex_eval(exarg_T *eap);
void ex_if(exarg_T *eap);
void ex_endif(exarg_T *eap);
*** ../vim-8.2.3375/src/vim9compile.c 2021-08-24 21:55:58.337276558 +0200
--- src/vim9compile.c 2021-08-25 22:19:44.377575326 +0200
***************
*** 8828,8844 ****
{
char_u *p = arg;
int name_only;
- char_u *alias;
long lnum = SOURCING_LNUM;

// find_ex_command() will consider a variable name an expression, assuming
// that something follows on the next line. Check that something actually
// follows, otherwise it's probably a misplaced command.
! get_name_len(&p, &alias, FALSE, FALSE);
! name_only = ends_excmd2(arg, skipwhite(p));
! vim_free(alias);

- p = arg;
if (compile_expr0(&p, cctx) == FAIL)
return NULL;

--- 8828,8840 ----
{
char_u *p = arg;
int name_only;
long lnum = SOURCING_LNUM;

// find_ex_command() will consider a variable name an expression, assuming
// that something follows on the next line. Check that something actually
// follows, otherwise it's probably a misplaced command.
! name_only = cmd_is_name_only(arg);

if (compile_expr0(&p, cctx) == FAIL)
return NULL;

*** ../vim-8.2.3375/src/testdir/test_vim9_cmd.vim 2021-08-24 21:55:58.337276558 +0200
--- src/testdir/test_vim9_cmd.vim 2021-08-25 21:57:49.660293275 +0200
***************
*** 537,543 ****
CheckDefAndScriptSuccess(lines)
enddef

! def Test_register_use_linebreak()
var lines =<< trim END
new
@a = 'one'
--- 537,543 ----
CheckDefAndScriptSuccess(lines)
enddef

! def Test_use_register()
var lines =<< trim END
new
@a = 'one'
***************
*** 551,556 ****
--- 551,562 ----
bwipe!
END
CheckDefAndScriptSuccess(lines)
+
+ lines =<< trim END
+ @a = 'echo "text"'
+ @a
+ END
+ CheckDefAndScriptFailure(lines, 'E1207:')
enddef

def Test_environment_use_linebreak()
*** ../vim-8.2.3375/src/version.c 2021-08-25 17:31:29.845375905 +0200
--- src/version.c 2021-08-25 21:55:05.544661541 +0200
***************
*** 757,758 ****
--- 757,760 ----
{ /* Add new patch number below this line */
+ /**/
+ 3376,
/**/

--
SOLDIER: Where did you get the coconuts?
ARTHUR: Through ... We found them.
SOLDIER: Found them? In Mercea. The coconut's tropical!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages