Mercurial > vim
comparison src/vim9compile.c @ 21648:33fec2448697 v8.2.1374
patch 8.2.1374: Vim9: error for assigning empty list to script variable
Commit: https://github.com/vim/vim/commit/a71e2633207557c31432c954194078cb6062d04f
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Aug 5 15:11:03 2020 +0200
patch 8.2.1374: Vim9: error for assigning empty list to script variable
Problem: Vim9: error for assigning empty list to script variable.
Solution: Use t_unknown for empty list member. (closes https://github.com/vim/vim/issues/6595)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 05 Aug 2020 15:15:03 +0200 |
parents | a640bc762196 |
children | 79a8d723a3d2 |
comparison
equal
deleted
inserted
replaced
21647:03d8640840f5 | 21648:33fec2448697 |
---|---|
500 if (tv->v_type == VAR_BOOL) | 500 if (tv->v_type == VAR_BOOL) |
501 return &t_bool; // not used | 501 return &t_bool; // not used |
502 if (tv->v_type == VAR_STRING) | 502 if (tv->v_type == VAR_STRING) |
503 return &t_string; | 503 return &t_string; |
504 | 504 |
505 if (tv->v_type == VAR_LIST | 505 if (tv->v_type == VAR_LIST) |
506 && tv->vval.v_list != NULL | 506 { |
507 && tv->vval.v_list->lv_first != NULL) | 507 if (tv->vval.v_list == NULL || tv->vval.v_list->lv_first == NULL) |
508 { | 508 return &t_list_empty; |
509 | |
509 // Use the type of the first member, it is the most specific. | 510 // Use the type of the first member, it is the most specific. |
510 member_type = typval2type(&tv->vval.v_list->lv_first->li_tv, type_gap); | 511 member_type = typval2type(&tv->vval.v_list->lv_first->li_tv, type_gap); |
511 return get_list_type(member_type, type_gap); | 512 return get_list_type(member_type, type_gap); |
512 } | 513 } |
513 | 514 |
514 if (tv->v_type == VAR_DICT | 515 if (tv->v_type == VAR_DICT) |
515 && tv->vval.v_dict != NULL | |
516 && tv->vval.v_dict->dv_hashtab.ht_used > 0) | |
517 { | 516 { |
518 dict_iterator_T iter; | 517 dict_iterator_T iter; |
519 typval_T *value; | 518 typval_T *value; |
519 | |
520 if (tv->vval.v_dict == NULL | |
521 || tv->vval.v_dict->dv_hashtab.ht_used == 0) | |
522 return &t_dict_empty; | |
520 | 523 |
521 // Use the type of the first value, it is the most specific. | 524 // Use the type of the first value, it is the most specific. |
522 dict_iterate_start(tv, &iter); | 525 dict_iterate_start(tv, &iter); |
523 dict_iterate_next(&iter, &value); | 526 dict_iterate_next(&iter, &value); |
524 member_type = typval2type(value, type_gap); | 527 member_type = typval2type(value, type_gap); |