Mercurial > vim
changeset 21949:e6608764248a v8.2.1524
patch 8.2.1524: no longer get an error for string concatenation with float
Commit: https://github.com/vim/vim/commit/2e0866128b6266829a7f38733d5188bc4ec68745
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Aug 25 22:37:48 2020 +0200
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 25 Aug 2020 22:45:03 +0200 |
parents | 73cc8556f84a |
children | e92c113380c5 |
files | src/eval.c src/testdir/test_eval_stuff.vim src/version.c |
diffstat | 3 files changed, 14 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/eval.c +++ b/src/eval.c @@ -2675,6 +2675,7 @@ eval5(char_u **arg, typval_T *rettv, eva 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, eva *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, eva /* * 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, eva 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);
--- 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