Skip to content

Commit 2e08661

Browse files
committed
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)
1 parent b9fc192 commit 2e08661

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

src/eval.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2675,6 +2675,7 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
26752675
int oplen;
26762676
int concat;
26772677
typval_T var2;
2678+
int vim9script = in_vim9script();
26782679

26792680
// "." is only string concatenation when scriptversion is 1
26802681
p = eval_next_non_blank(*arg, evalarg, &getnext);
@@ -2689,7 +2690,7 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
26892690
*arg = eval_next_line(evalarg);
26902691
else
26912692
{
2692-
if (evaluate && in_vim9script() && !VIM_ISWHITE(**arg))
2693+
if (evaluate && vim9script && !VIM_ISWHITE(**arg))
26932694
{
26942695
error_white_both(p, oplen);
26952696
clear_tv(rettv);
@@ -2721,14 +2722,14 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
27212722
/*
27222723
* Get the second variable.
27232724
*/
2724-
if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[oplen]))
2725+
if (evaluate && vim9script && !IS_WHITE_OR_NUL((*arg)[oplen]))
27252726
{
27262727
error_white_both(p, oplen);
27272728
clear_tv(rettv);
27282729
return FAIL;
27292730
}
27302731
*arg = skipwhite_and_linebreak(*arg + oplen, evalarg);
2731-
if (eval6(arg, &var2, evalarg, !in_vim9script() && op == '.') == FAIL)
2732+
if (eval6(arg, &var2, evalarg, !vim9script && op == '.') == FAIL)
27322733
{
27332734
clear_tv(rettv);
27342735
return FAIL;
@@ -2745,12 +2746,12 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
27452746
char_u *s1 = tv_get_string_buf(rettv, buf1);
27462747
char_u *s2 = NULL;
27472748

2748-
if (in_vim9script() && (var2.v_type == VAR_VOID
2749+
if (vim9script && (var2.v_type == VAR_VOID
27492750
|| var2.v_type == VAR_CHANNEL
27502751
|| var2.v_type == VAR_JOB))
27512752
emsg(_(e_inval_string));
27522753
#ifdef FEAT_FLOAT
2753-
else if (var2.v_type == VAR_FLOAT)
2754+
else if (vim9script && var2.v_type == VAR_FLOAT)
27542755
{
27552756
vim_snprintf((char *)buf2, NUMBUFLEN, "%g",
27562757
var2.vval.v_float);

src/testdir/test_eval_stuff.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ func Test_string_concatenation()
135135
let a = 'a'
136136
let a..=b
137137
call assert_equal('ab', a)
138+
139+
if has('float')
140+
let a = 'A'
141+
let b = 1.234
142+
call assert_fails('echo a .. b', 'E806:')
143+
endif
138144
endfunc
139145

140146
" Test fix for issue #4507

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ static char *(features[]) =
754754

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
1524,
757759
/**/
758760
1523,
759761
/**/

0 commit comments

Comments
 (0)