Mercurial > vim
diff src/vim9execute.c @ 21771:fcf978444298 v8.2.1435
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Commit: https://github.com/vim/vim/commit/418f1df54763b79600db1c91c880fbc1007b2e1f
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Aug 12 21:34:49 2020 +0200
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Problem: Vim9: always converting to string for ".." leads to mistakes.
Solution: Only automatically convert simple types.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 12 Aug 2020 21:45:03 +0200 |
parents | 6c03897bcd60 |
children | 837e6a429950 |
line wrap: on
line diff
--- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -72,6 +72,12 @@ typedef struct { // Get pointer to item relative to the bottom of the stack, -1 is the last one. #define STACK_TV_BOT(idx) (((typval_T *)ectx->ec_stack.ga_data) + ectx->ec_stack.ga_len + idx) + void +to_string_error(vartype_T vartype) +{ + semsg(_("E1105: Cannot convert %s to string"), vartype_name(vartype)); +} + /* * Return the number of arguments, including optional arguments and any vararg. */ @@ -2476,12 +2482,26 @@ call_def_function( break; case ISN_2STRING: + case ISN_2STRING_ANY: { char_u *str; tv = STACK_TV_BOT(iptr->isn_arg.number); if (tv->v_type != VAR_STRING) { + if (iptr->isn_type == ISN_2STRING_ANY) + { + switch (tv->v_type) + { + case VAR_SPECIAL: + case VAR_BOOL: + case VAR_NUMBER: + case VAR_FLOAT: + case VAR_BLOB: break; + default: to_string_error(tv->v_type); + goto on_error; + } + } str = typval_tostring(tv); clear_tv(tv); tv->v_type = VAR_STRING; @@ -3127,6 +3147,9 @@ ex_disassemble(exarg_T *eap) case ISN_2STRING: smsg("%4d 2STRING stack[%lld]", current, (long long)(iptr->isn_arg.number)); break; + case ISN_2STRING_ANY: smsg("%4d 2STRING_ANY stack[%lld]", current, + (long long)(iptr->isn_arg.number)); + break; case ISN_SHUFFLE: smsg("%4d SHUFFLE %d up %d", current, iptr->isn_arg.shuffle.shfl_item,