Patch 8.2.2628
Problem:    Vim9: #{ can still be used at the script level.
Solution:   Give an error for #{ like in a :def function.
Files:      src/eval.c, src/ex_docmd.c, src/testdir/test_vim9_expr.vim


*** ../vim-8.2.2627/src/eval.c  2021-03-13 20:57:15.855515074 +0100
--- src/eval.c  2021-03-20 13:22:25.247829890 +0100
***************
*** 2228,2234 ****
        if (!aborting()
                && did_emsg == did_emsg_before
                && called_emsg == called_emsg_before
!               && (flags & EVAL_CONSTANT) == 0)
            semsg(_(e_invexpr2), arg);
  
        // Some of the expression may not have been consumed.  Do not check for
--- 2228,2235 ----
        if (!aborting()
                && did_emsg == did_emsg_before
                && called_emsg == called_emsg_before
!               && (flags & EVAL_CONSTANT) == 0
!               && (!in_vim9script() || !vim9_bad_comment(p)))
            semsg(_(e_invexpr2), arg);
  
        // Some of the expression may not have been consumed.  Do not check for
***************
*** 3362,3368 ****
      /*
       * Dictionary: #{key: val, key: val}
       */
!     case '#': if (!in_vim9script() && (*arg)[1] == '{')
                {
                    ++*arg;
                    ret = eval_dict(arg, rettv, evalarg, TRUE);
--- 3363,3373 ----
      /*
       * Dictionary: #{key: val, key: val}
       */
!     case '#': if (in_vim9script())
!               {
!                   ret = vim9_bad_comment(*arg) ? FAIL : NOTDONE;
!               }
!               else if ((*arg)[1] == '{')
                {
                    ++*arg;
                    ret = eval_dict(arg, rettv, evalarg, TRUE);
*** ../vim-8.2.2627/src/ex_docmd.c      2021-03-14 13:21:31.785065163 +0100
--- src/ex_docmd.c      2021-03-20 13:18:10.412647594 +0100
***************
*** 5234,5240 ****
        return TRUE;
  #ifdef FEAT_EVAL
      if (in_vim9script())
!       return c == '#' && (cmd == cmd_start || VIM_ISWHITE(cmd[-1]));
  #endif
      return c == '"';
  }
--- 5234,5241 ----
        return TRUE;
  #ifdef FEAT_EVAL
      if (in_vim9script())
!       return c == '#' && cmd[1] != '{'
!                                && (cmd == cmd_start || VIM_ISWHITE(cmd[-1]));
  #endif
      return c == '"';
  }
*** ../vim-8.2.2627/src/testdir/test_vim9_expr.vim      2021-03-18 
21:37:52.196105245 +0100
--- src/testdir/test_vim9_expr.vim      2021-03-20 12:56:50.848751854 +0100
***************
*** 2159,2168 ****
    CheckDefAndScriptSuccess(lines)
   
    # legacy syntax doesn't work
!   CheckDefFailure(["var x = #{key: 8}"], 'E1170:', 1)
!   CheckDefFailure(["var x = 'a' #{a: 1}"], 'E1170:', 1)
!   CheckDefFailure(["var x = 'a' .. #{a: 1}"], 'E1170:', 1)
!   CheckDefFailure(["var x = true ? #{a: 1}"], 'E1170:', 1)
  
    CheckDefFailure(["var x = {a:8}"], 'E1069:', 1)
    CheckDefFailure(["var x = {a : 8}"], 'E1068:', 1)
--- 2159,2168 ----
    CheckDefAndScriptSuccess(lines)
   
    # legacy syntax doesn't work
!   CheckDefAndScriptFailure(["var x = #{key: 8}"], 'E1170:', 1)
!   CheckDefAndScriptFailure(["var x = 'a' #{a: 1}"], 'E1170:', 1)
!   CheckDefAndScriptFailure(["var x = 'a' .. #{a: 1}"], 'E1170:', 1)
!   CheckDefAndScriptFailure(["var x = true ? #{a: 1}"], 'E1170:', 1)
  
    CheckDefFailure(["var x = {a:8}"], 'E1069:', 1)
    CheckDefFailure(["var x = {a : 8}"], 'E1068:', 1)
*** ../vim-8.2.2627/src/version.c       2021-03-20 12:49:12.078222904 +0100
--- src/version.c       2021-03-20 13:28:59.103468313 +0100
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2628,
  /**/

-- 
A)bort, R)etry, P)lease don't bother me again

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202103201230.12KCUCkw1777108%40masaka.moolenaar.net.

Raspunde prin e-mail lui