comparison src/vim9compile.c @ 19423:f3e8e74cb747 v8.2.0269

patch 8.2.0269: Vim9: operator after list index does not work Commit: https://github.com/vim/vim/commit/b13af50f73dd89503c915f76fcf92be58789521a Author: Bram Moolenaar <Bram@vim.org> Date: Mon Feb 17 21:12:08 2020 +0100 patch 8.2.0269: Vim9: operator after list index does not work Problem: Vim9: operator after list index does not work. (Yasuhiro Matsumoto) Solution: After indexing a list change the type to the list member type. (closes #5651)
author Bram Moolenaar <Bram@vim.org>
date Mon, 17 Feb 2020 21:15:05 +0100
parents bc880a130120
children 5d34ae66118e
comparison
equal deleted inserted replaced
19422:e5cd953790be 19423:f3e8e74cb747
2328 return FAIL; 2328 return FAIL;
2329 } 2329 }
2330 } 2330 }
2331 else if (**arg == '[') 2331 else if (**arg == '[')
2332 { 2332 {
2333 garray_T *stack;
2334 type_T **typep;
2335
2333 // list index: list[123] 2336 // list index: list[123]
2334 // TODO: more arguments 2337 // TODO: more arguments
2335 // TODO: dict member dict['name'] 2338 // TODO: dict member dict['name']
2336 *arg = skipwhite(*arg + 1); 2339 *arg = skipwhite(*arg + 1);
2337 if (compile_expr1(arg, cctx) == FAIL) 2340 if (compile_expr1(arg, cctx) == FAIL)
2344 } 2347 }
2345 *arg = *arg + 1; 2348 *arg = *arg + 1;
2346 2349
2347 if (generate_instr_drop(cctx, ISN_INDEX, 1) == FAIL) 2350 if (generate_instr_drop(cctx, ISN_INDEX, 1) == FAIL)
2348 return FAIL; 2351 return FAIL;
2352 stack = &cctx->ctx_type_stack;
2353 typep = ((type_T **)stack->ga_data) + stack->ga_len - 1;
2354 if ((*typep)->tt_type != VAR_LIST && *typep != &t_any)
2355 {
2356 emsg(_(e_listreq));
2357 return FAIL;
2358 }
2359 *typep = (*typep)->tt_member;
2349 } 2360 }
2350 else if (**arg == '.' && (*arg)[1] != '.') 2361 else if (**arg == '.' && (*arg)[1] != '.')
2351 { 2362 {
2352 char_u *p; 2363 char_u *p;
2353 2364