summaryrefslogtreecommitdiffstats
path: root/src/vim9execute.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vim9execute.c')
-rw-r--r--src/vim9execute.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/vim9execute.c b/src/vim9execute.c
index 1efed35..3a3960a 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -260,7 +260,10 @@ exe_newdict(int count, ectx_T *ectx)
if (count > 0)
ectx->ec_stack.ga_len -= 2 * count - 1;
else if (GA_GROW_FAILS(&ectx->ec_stack, 1))
+ {
+ dict_unref(dict);
return FAIL;
+ }
else
++ectx->ec_stack.ga_len;
tv = STACK_TV_BOT(-1);
@@ -1635,7 +1638,7 @@ store_var(char_u *name, typval_T *tv)
* Return FAIL if not allowed.
*/
static int
-do_2string(typval_T *tv, int is_2string_any, int tolerant)
+do_2string(typval_T *tv, int is_2string_any, int tostring_flags)
{
if (tv->v_type == VAR_STRING)
return OK;
@@ -1650,10 +1653,11 @@ do_2string(typval_T *tv, int is_2string_any, int tolerant)
case VAR_BOOL:
case VAR_NUMBER:
case VAR_FLOAT:
+ case VAR_DICT:
case VAR_BLOB: break;
case VAR_LIST:
- if (tolerant)
+ if (tostring_flags & TOSTRING_TOLERANT)
{
char_u *s, *e, *p;
garray_T ga;
@@ -1686,6 +1690,8 @@ do_2string(typval_T *tv, int is_2string_any, int tolerant)
tv->vval.v_string = ga.ga_data;
return OK;
}
+ if (tostring_flags & TOSTRING_INTERPOLATE)
+ break;
// FALLTHROUGH
default: to_string_error(tv->v_type);
return FAIL;
@@ -3255,6 +3261,12 @@ exec_instructions(ectx_T *ectx)
++tv->vval.v_object->obj_class->class_refcount;
tv->vval.v_object->obj_refcount = 1;
object_created(tv->vval.v_object);
+
+ // When creating an enum value object, initialize the name and
+ // ordinal object variables.
+ class_T *en = tv->vval.v_object->obj_class;
+ if (IS_ENUM(en))
+ enum_set_internal_obj_vars(en, tv->vval.v_object);
break;
// execute Ex command line
@@ -3830,11 +3842,19 @@ exec_instructions(ectx_T *ectx)
case ISN_STOREEXPORT:
{
int sid = iptr->isn_arg.loadstore.ls_sid;
- hashtab_T *ht = &SCRIPT_VARS(sid);
char_u *name = iptr->isn_arg.loadstore.ls_name;
- dictitem_T *di = find_var_in_ht(ht, 0,
- iptr->isn_type == ISN_STORES
+ dictitem_T *di = NULL;
+ // First check for a variable from an exported autoload
+ // with an autoload_prefix; it would be in globals.
+ if (iptr->isn_type == ISN_STOREEXPORT)
+ di = find_var_autoload_prefix(name, sid, NULL, NULL);
+ // Then look for a variable in the script's variables.
+ if (di == NULL)
+ {
+ hashtab_T *ht = &SCRIPT_VARS(sid);
+ di = find_var_in_ht(ht, 0, STRNCMP("s:", name, 2) == 0
? name + 2 : name, TRUE);
+ }
--ectx->ec_stack.ga_len;
SOURCING_LNUM = iptr->isn_lnum;
@@ -4564,6 +4584,7 @@ exec_instructions(ectx_T *ectx)
{
SOURCING_LNUM = iptr->isn_lnum;
iemsg("ufunc unexpectedly NULL for FUNCREF");
+ vim_free(pt);
goto theend;
}
if (fill_partial_and_closure(pt, ufunc,
@@ -5674,7 +5695,7 @@ exec_instructions(ectx_T *ectx)
SOURCING_LNUM = iptr->isn_lnum;
if (do_2string(STACK_TV_BOT(iptr->isn_arg.tostring.offset),
iptr->isn_type == ISN_2STRING_ANY,
- iptr->isn_arg.tostring.tolerant) == FAIL)
+ iptr->isn_arg.tostring.flags) == FAIL)
goto on_error;
break;