patch 9.0.1053: default constructor arguments are not optional
Problem: Default constructor arguments are not optional.
Solution: Use "= v:none" to make constructor arguments optional.
diff --git a/src/vim9execute.c b/src/vim9execute.c
index 6a6ec41..1a8058a 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -2068,7 +2068,7 @@
}
/*
- * Store a value in a list, dict or blob variable.
+ * Store a value in a list, dict, blob or object variable.
* Returns OK, FAIL or NOTDONE (uncatchable error).
*/
static int
@@ -2177,9 +2177,9 @@
{
long lidx = (long)tv_idx->vval.v_number;
blob_T *blob = tv_dest->vval.v_blob;
- varnumber_T nr;
- int error = FALSE;
- int len;
+ varnumber_T nr;
+ int error = FALSE;
+ int len;
if (blob == NULL)
{
@@ -2209,6 +2209,7 @@
long idx = (long)tv_idx->vval.v_number;
object_T *obj = tv_dest->vval.v_object;
typval_T *otv = (typval_T *)(obj + 1);
+ clear_tv(&otv[idx]);
otv[idx] = *tv;
}
else
@@ -4293,10 +4294,12 @@
// Jump if an argument with a default value was already set and not
// v:none.
case ISN_JUMP_IF_ARG_SET:
+ case ISN_JUMP_IF_ARG_NOT_SET:
tv = STACK_TV_VAR(iptr->isn_arg.jumparg.jump_arg_off);
- if (tv->v_type != VAR_UNKNOWN
- && !(tv->v_type == VAR_SPECIAL
- && tv->vval.v_number == VVAL_NONE))
+ int arg_set = tv->v_type != VAR_UNKNOWN
+ && !(tv->v_type == VAR_SPECIAL
+ && tv->vval.v_number == VVAL_NONE);
+ if (iptr->isn_type == ISN_JUMP_IF_ARG_SET ? arg_set : !arg_set)
ectx->ec_iidx = iptr->isn_arg.jumparg.jump_where;
break;
@@ -6633,6 +6636,12 @@
iptr->isn_arg.jump.jump_where);
break;
+ case ISN_JUMP_IF_ARG_NOT_SET:
+ smsg("%s%4d JUMP_IF_ARG_NOT_SET arg[%d] -> %d", pfx, current,
+ iptr->isn_arg.jumparg.jump_arg_off + STACK_FRAME_SIZE,
+ iptr->isn_arg.jump.jump_where);
+ break;
+
case ISN_FOR:
{
forloop_T *forloop = &iptr->isn_arg.forloop;