Mercurial > vim
comparison src/vim9execute.c @ 31441:e572ff386670 v9.0.1053
patch 9.0.1053: default constructor arguments are not optional
Commit: https://github.com/vim/vim/commit/65b0d1676814ee08fb58ef8d64dd342d1d883192
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Dec 13 18:43:22 2022 +0000
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 13 Dec 2022 19:45:04 +0100 |
parents | e31fc75f6aff |
children | 1bebc2093e6b |
comparison
equal
deleted
inserted
replaced
31440:5a24ca193fe9 | 31441:e572ff386670 |
---|---|
2066 if (end_lnum > iptr->isn_lnum) | 2066 if (end_lnum > iptr->isn_lnum) |
2067 vim_free(line); | 2067 vim_free(line); |
2068 } | 2068 } |
2069 | 2069 |
2070 /* | 2070 /* |
2071 * Store a value in a list, dict or blob variable. | 2071 * Store a value in a list, dict, blob or object variable. |
2072 * Returns OK, FAIL or NOTDONE (uncatchable error). | 2072 * Returns OK, FAIL or NOTDONE (uncatchable error). |
2073 */ | 2073 */ |
2074 static int | 2074 static int |
2075 execute_storeindex(isn_T *iptr, ectx_T *ectx) | 2075 execute_storeindex(isn_T *iptr, ectx_T *ectx) |
2076 { | 2076 { |
2175 } | 2175 } |
2176 else if (dest_type == VAR_BLOB) | 2176 else if (dest_type == VAR_BLOB) |
2177 { | 2177 { |
2178 long lidx = (long)tv_idx->vval.v_number; | 2178 long lidx = (long)tv_idx->vval.v_number; |
2179 blob_T *blob = tv_dest->vval.v_blob; | 2179 blob_T *blob = tv_dest->vval.v_blob; |
2180 varnumber_T nr; | 2180 varnumber_T nr; |
2181 int error = FALSE; | 2181 int error = FALSE; |
2182 int len; | 2182 int len; |
2183 | 2183 |
2184 if (blob == NULL) | 2184 if (blob == NULL) |
2185 { | 2185 { |
2186 emsg(_(e_blob_not_set)); | 2186 emsg(_(e_blob_not_set)); |
2187 return FAIL; | 2187 return FAIL; |
2207 else if (dest_type == VAR_CLASS || dest_type == VAR_OBJECT) | 2207 else if (dest_type == VAR_CLASS || dest_type == VAR_OBJECT) |
2208 { | 2208 { |
2209 long idx = (long)tv_idx->vval.v_number; | 2209 long idx = (long)tv_idx->vval.v_number; |
2210 object_T *obj = tv_dest->vval.v_object; | 2210 object_T *obj = tv_dest->vval.v_object; |
2211 typval_T *otv = (typval_T *)(obj + 1); | 2211 typval_T *otv = (typval_T *)(obj + 1); |
2212 clear_tv(&otv[idx]); | |
2212 otv[idx] = *tv; | 2213 otv[idx] = *tv; |
2213 } | 2214 } |
2214 else | 2215 else |
2215 { | 2216 { |
2216 status = FAIL; | 2217 status = FAIL; |
4291 break; | 4292 break; |
4292 | 4293 |
4293 // Jump if an argument with a default value was already set and not | 4294 // Jump if an argument with a default value was already set and not |
4294 // v:none. | 4295 // v:none. |
4295 case ISN_JUMP_IF_ARG_SET: | 4296 case ISN_JUMP_IF_ARG_SET: |
4297 case ISN_JUMP_IF_ARG_NOT_SET: | |
4296 tv = STACK_TV_VAR(iptr->isn_arg.jumparg.jump_arg_off); | 4298 tv = STACK_TV_VAR(iptr->isn_arg.jumparg.jump_arg_off); |
4297 if (tv->v_type != VAR_UNKNOWN | 4299 int arg_set = tv->v_type != VAR_UNKNOWN |
4298 && !(tv->v_type == VAR_SPECIAL | 4300 && !(tv->v_type == VAR_SPECIAL |
4299 && tv->vval.v_number == VVAL_NONE)) | 4301 && tv->vval.v_number == VVAL_NONE); |
4302 if (iptr->isn_type == ISN_JUMP_IF_ARG_SET ? arg_set : !arg_set) | |
4300 ectx->ec_iidx = iptr->isn_arg.jumparg.jump_where; | 4303 ectx->ec_iidx = iptr->isn_arg.jumparg.jump_where; |
4301 break; | 4304 break; |
4302 | 4305 |
4303 // top of a for loop | 4306 // top of a for loop |
4304 case ISN_FOR: | 4307 case ISN_FOR: |
6627 } | 6630 } |
6628 break; | 6631 break; |
6629 | 6632 |
6630 case ISN_JUMP_IF_ARG_SET: | 6633 case ISN_JUMP_IF_ARG_SET: |
6631 smsg("%s%4d JUMP_IF_ARG_SET arg[%d] -> %d", pfx, current, | 6634 smsg("%s%4d JUMP_IF_ARG_SET arg[%d] -> %d", pfx, current, |
6635 iptr->isn_arg.jumparg.jump_arg_off + STACK_FRAME_SIZE, | |
6636 iptr->isn_arg.jump.jump_where); | |
6637 break; | |
6638 | |
6639 case ISN_JUMP_IF_ARG_NOT_SET: | |
6640 smsg("%s%4d JUMP_IF_ARG_NOT_SET arg[%d] -> %d", pfx, current, | |
6632 iptr->isn_arg.jumparg.jump_arg_off + STACK_FRAME_SIZE, | 6641 iptr->isn_arg.jumparg.jump_arg_off + STACK_FRAME_SIZE, |
6633 iptr->isn_arg.jump.jump_where); | 6642 iptr->isn_arg.jump.jump_where); |
6634 break; | 6643 break; |
6635 | 6644 |
6636 case ISN_FOR: | 6645 case ISN_FOR: |