diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-08-12 21:34:49 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-08-12 21:34:49 +0200 |
commit | 418f1df54763b79600db1c91c880fbc1007b2e1f (patch) | |
tree | 5ffaf68d304881ef490608d00e4a1ed4df04ed4a /src/eval.c | |
parent | fd77748df2ba7d5f38aab649cb630374620462d7 (diff) | |
download | vim-git-418f1df54763b79600db1c91c880fbc1007b2e1f.tar.gz |
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakesv8.2.1435
Problem: Vim9: always converting to string for ".." leads to mistakes.
Solution: Only automatically convert simple types.
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/eval.c b/src/eval.c index 99554e7e2..07b30c723 100644 --- a/src/eval.c +++ b/src/eval.c @@ -2712,7 +2712,7 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg) return FAIL; } *arg = skipwhite_and_linebreak(*arg + oplen, evalarg); - if (eval6(arg, &var2, evalarg, op == '.') == FAIL) + if (eval6(arg, &var2, evalarg, !in_vim9script() && op == '.') == FAIL) { clear_tv(rettv); return FAIL; @@ -2727,8 +2727,22 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg) { char_u buf1[NUMBUFLEN], buf2[NUMBUFLEN]; char_u *s1 = tv_get_string_buf(rettv, buf1); - char_u *s2 = tv_get_string_buf_chk(&var2, buf2); + char_u *s2 = NULL; + if (in_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) + { + vim_snprintf((char *)buf2, NUMBUFLEN, "%g", + var2.vval.v_float); + s2 = buf2; + } +#endif + else + s2 = tv_get_string_buf_chk(&var2, buf2); if (s2 == NULL) // type error ? { clear_tv(rettv); |