Mercurial > vim
comparison src/vim9type.c @ 27503:4cea92e99a5a v8.2.4279
patch 8.2.4279: Vim9: cannot change item type with map() after range()
Commit: https://github.com/vim/vim/commit/8133018f50bc447570825801e93d5ed67e8dac90
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Feb 1 12:11:58 2022 +0000
patch 8.2.4279: Vim9: cannot change item type with map() after range()
Problem: Vim9: cannot change item type with map() after range().
Solution: Split the return type in current type and declared type.
(closes #9665)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 01 Feb 2022 13:15:03 +0100 |
parents | 374c7d5a096a |
children | f00a7a2bee21 |
comparison
equal
deleted
inserted
replaced
27502:aad2a09123be | 27503:4cea92e99a5a |
---|---|
355 { | 355 { |
356 int idx = find_internal_func(name); | 356 int idx = find_internal_func(name); |
357 | 357 |
358 if (idx >= 0) | 358 if (idx >= 0) |
359 { | 359 { |
360 type_T *decl_type; // unused | |
361 | |
360 internal_func_get_argcount(idx, &argcount, &min_argcount); | 362 internal_func_get_argcount(idx, &argcount, &min_argcount); |
361 member_type = internal_func_ret_type(idx, 0, NULL); | 363 member_type = internal_func_ret_type(idx, 0, NULL, &decl_type); |
362 } | 364 } |
363 else | 365 else |
364 ufunc = find_func(name, FALSE); | 366 ufunc = find_func(name, FALSE); |
365 } | 367 } |
366 if (ufunc != NULL) | 368 if (ufunc != NULL) |
1242 typep->type_curr = type; | 1244 typep->type_curr = type; |
1243 typep->type_decl = &t_any; | 1245 typep->type_decl = &t_any; |
1244 } | 1246 } |
1245 | 1247 |
1246 /* | 1248 /* |
1247 * Get the type from the type stack. If "offset" is zero the one at the top, | 1249 * Get the current type from the type stack. If "offset" is zero the one at |
1250 * the top, | |
1248 * if "offset" is one the type above that, etc. | 1251 * if "offset" is one the type above that, etc. |
1249 * Returns &t_unknown if there is no such stack entry. | 1252 * Returns &t_unknown if there is no such stack entry. |
1250 */ | 1253 */ |
1251 type_T * | 1254 type_T * |
1252 get_type_on_stack(cctx_T *cctx, int offset) | 1255 get_type_on_stack(cctx_T *cctx, int offset) |
1255 | 1258 |
1256 if (offset + 1 > stack->ga_len) | 1259 if (offset + 1 > stack->ga_len) |
1257 return &t_unknown; | 1260 return &t_unknown; |
1258 return (((type2_T *)stack->ga_data) + stack->ga_len - offset - 1) | 1261 return (((type2_T *)stack->ga_data) + stack->ga_len - offset - 1) |
1259 ->type_curr; | 1262 ->type_curr; |
1263 } | |
1264 | |
1265 /* | |
1266 * Get the declared type from the type stack. If "offset" is zero the one at | |
1267 * the top, | |
1268 * if "offset" is one the type above that, etc. | |
1269 * Returns &t_unknown if there is no such stack entry. | |
1270 */ | |
1271 type_T * | |
1272 get_decl_type_on_stack(cctx_T *cctx, int offset) | |
1273 { | |
1274 garray_T *stack = &cctx->ctx_type_stack; | |
1275 | |
1276 if (offset + 1 > stack->ga_len) | |
1277 return &t_unknown; | |
1278 return (((type2_T *)stack->ga_data) + stack->ga_len - offset - 1) | |
1279 ->type_decl; | |
1260 } | 1280 } |
1261 | 1281 |
1262 /* | 1282 /* |
1263 * Get the member type of a dict or list from the items on the stack of "cctx". | 1283 * Get the member type of a dict or list from the items on the stack of "cctx". |
1264 * The declared type is stored in "decl_type". | 1284 * The declared type is stored in "decl_type". |