From 2e0866128b6266829a7f38733d5188bc4ec68745 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 25 Aug 2020 22:37:48 +0200 Subject: patch 8.2.1524: no longer get an error for string concatenation with float 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 | 11 ++++++----- src/testdir/test_eval_stuff.vim | 6 ++++++ src/version.c | 2 ++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/eval.c b/src/eval.c index 056ac76c2..2d2ad1b5f 100644 --- a/src/eval.c +++ b/src/eval.c @@ -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); diff --git a/src/testdir/test_eval_stuff.vim b/src/testdir/test_eval_stuff.vim index 02e7e14fd..1490ffbc5 100644 --- a/src/testdir/test_eval_stuff.vim +++ b/src/testdir/test_eval_stuff.vim @@ -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 diff --git a/src/version.c b/src/version.c index f977e2830..70fe7df1f 100644 --- a/src/version.c +++ b/src/version.c @@ -754,6 +754,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1524, /**/ 1523, /**/ -- cgit v1.2.1