Patch 9.0.0150
Problem:    Error for using #{ in an expression is a bit confusing.
Solution:   Mention that this error is only given for an expression.
            Avoid giving the error more than once. (closes #10855)
Files:      src/errors.h, src/vim9script.c, src/eval.c,
            src/testdir/test_vim9_expr.vim


*** ../vim-9.0.0149/src/errors.h        2022-07-27 13:18:10.127091809 +0100
--- src/errors.h        2022-08-06 11:15:54.306436195 +0100
***************
*** 2984,2991 ****
        INIT(= N_("E1168: Argument already declared in the script: %s"));
  EXTERN char e_expression_too_recursive_str[]
        INIT(= N_("E1169: Expression too recursive: %s"));
! EXTERN char e_cannot_use_hash_curly_to_start_comment[]
!       INIT(= N_("E1170: Cannot use #{ to start a comment"));
  EXTERN char e_missing_end_block[]
        INIT(= N_("E1171: Missing } after inline function"));
  EXTERN char e_cannot_use_default_values_in_lambda[]
--- 2984,2991 ----
        INIT(= N_("E1168: Argument already declared in the script: %s"));
  EXTERN char e_expression_too_recursive_str[]
        INIT(= N_("E1169: Expression too recursive: %s"));
! EXTERN char e_cannot_use_hash_curly_to_start_comment_in_an_expression[]
!       INIT(= N_("E1170: Cannot use #{ to start a comment in an expression"));
  EXTERN char e_missing_end_block[]
        INIT(= N_("E1171: Missing } after inline function"));
  EXTERN char e_cannot_use_default_values_in_lambda[]
*** ../vim-9.0.0149/src/vim9script.c    2022-05-26 19:41:57.000000000 +0100
--- src/vim9script.c    2022-08-06 11:15:38.326444797 +0100
***************
*** 183,191 ****
      int
  vim9_bad_comment(char_u *p)
  {
!     if (p[0] == '#' && p[1] == '{' && p[2] != '{')
      {
!       emsg(_(e_cannot_use_hash_curly_to_start_comment));
        return TRUE;
      }
      return FALSE;
--- 183,191 ----
      int
  vim9_bad_comment(char_u *p)
  {
!     if (!did_emsg && p[0] == '#' && p[1] == '{' && p[2] != '{')
      {
!       emsg(_(e_cannot_use_hash_curly_to_start_comment_in_an_expression));
        return TRUE;
      }
      return FALSE;
*** ../vim-9.0.0149/src/eval.c  2022-06-27 20:12:12.000000000 +0100
--- src/eval.c  2022-08-06 11:24:10.038147466 +0100
***************
*** 2157,2162 ****
--- 2157,2164 ----
                    break;
            p = nl;
        }
+       else if (vim9_bad_comment(p))
+           break;
        if (*p != NL)
            break;
        ++p;  // skip another NL
***************
*** 2182,2188 ****
--- 2184,2193 ----
            break;
        p = skipwhite(next);
        if (*p != NUL && !vim9_comment_start(p))
+       {
+           (void)vim9_bad_comment(p);
            return next;
+       }
        if (eval_next_line(NULL, evalarg) == NULL)
            break;
      }
*** ../vim-9.0.0149/src/testdir/test_vim9_expr.vim      2022-05-22 
18:25:44.000000000 +0100
--- src/testdir/test_vim9_expr.vim      2022-08-06 11:32:06.518831202 +0100
***************
*** 2823,2828 ****
--- 2823,2830 ----
    v9.CheckDefAndScriptFailure(["var x = 'a' .. #{a: 1}"], 'E1170:', 1)
    v9.CheckDefAndScriptFailure(["var x = true ? #{a: 1}"], 'E1170:', 1)
  
+   v9.CheckDefAndScriptFailure(["var x = 'a'", " #{a: 1}"], 'E1170:', 1)
+ 
    v9.CheckDefAndScriptFailure(["var x = {a:8}"], 'E1069:', 1)
    v9.CheckDefAndScriptFailure(["var x = {a : 8}"], 'E1068:', 1)
    v9.CheckDefAndScriptFailure(["var x = {a :8}"], 'E1068:', 1)
*** ../vim-9.0.0149/src/version.c       2022-08-06 10:28:15.665426324 +0100
--- src/version.c       2022-08-06 11:15:21.562453755 +0100
***************
*** 737,738 ****
--- 737,740 ----
  {   /* Add new patch number below this line */
+ /**/
+     150,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
253. You wait for a slow loading web page before going to the toilet.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            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/20220806103608.BF60E1C0EC3%40moolenaar.net.

Raspunde prin e-mail lui