]> granicus.if.org Git - vim/commitdiff
patch 8.2.1524: no longer get an error for string concatenation with float v8.2.1524
authorBram Moolenaar <Bram@vim.org>
Tue, 25 Aug 2020 20:37:48 +0000 (22:37 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 25 Aug 2020 20:37:48 +0000 (22:37 +0200)
Problem:    No longer get an error for string concatenation with float.
            (Tsuyoshi Cho)
Solution:   Only convert float for Vim9 script. (closes #6787)

src/eval.c
src/testdir/test_eval_stuff.vim
src/version.c

index 056ac76c2aa64bd6fbcb1603dfd01a8cdf994126..2d2ad1b5fa2b8399c6c7940dcad5b034735320a8 100644 (file)
@@ -2675,6 +2675,7 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
        int         oplen;
        int         concat;
        typval_T    var2;
+       int         vim9script = in_vim9script();
 
        // "." is only string concatenation when scriptversion is 1
        p = eval_next_non_blank(*arg, evalarg, &getnext);
@@ -2689,7 +2690,7 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
            *arg = eval_next_line(evalarg);
        else
        {
-           if (evaluate && in_vim9script() && !VIM_ISWHITE(**arg))
+           if (evaluate && vim9script && !VIM_ISWHITE(**arg))
            {
                error_white_both(p, oplen);
                clear_tv(rettv);
@@ -2721,14 +2722,14 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
        /*
         * Get the second variable.
         */
-       if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[oplen]))
+       if (evaluate && vim9script && !IS_WHITE_OR_NUL((*arg)[oplen]))
        {
            error_white_both(p, oplen);
            clear_tv(rettv);
            return FAIL;
        }
        *arg = skipwhite_and_linebreak(*arg + oplen, evalarg);
-       if (eval6(arg, &var2, evalarg, !in_vim9script() && op == '.') == FAIL)
+       if (eval6(arg, &var2, evalarg, !vim9script && op == '.') == FAIL)
        {
            clear_tv(rettv);
            return FAIL;
@@ -2745,12 +2746,12 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
                char_u  *s1 = tv_get_string_buf(rettv, buf1);
                char_u  *s2 = NULL;
 
-               if (in_vim9script() && (var2.v_type == VAR_VOID
+               if (vim9script && (var2.v_type == VAR_VOID
                        || var2.v_type == VAR_CHANNEL
                        || var2.v_type == VAR_JOB))
                    emsg(_(e_inval_string));
 #ifdef FEAT_FLOAT
-               else if (var2.v_type == VAR_FLOAT)
+               else if (vim9script && var2.v_type == VAR_FLOAT)
                {
                    vim_snprintf((char *)buf2, NUMBUFLEN, "%g",
                                                            var2.vval.v_float);
index 02e7e14fd7e0719cb3168f0dafc5dc4bee1ab2e5..1490ffbc57897270c6120ce24974d871afd7e9f2 100644 (file)
@@ -135,6 +135,12 @@ func Test_string_concatenation()
   let a = 'a'
   let a..=b
   call assert_equal('ab', a)
+
+  if has('float')
+    let a = 'A'
+    let b = 1.234
+    call assert_fails('echo a .. b', 'E806:')
+  endif
 endfunc
 
 " Test fix for issue #4507
index f977e28307bf52bdeefd9d6a40f2a7cfa34f4579..70fe7df1f7328ba32d41926f910758595b2fba8a 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1524,
 /**/
     1523,
 /**/