diff options
author | Ernie Rael <errael@raelity.com> | 2023-12-14 20:06:39 +0100 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2023-12-14 20:06:39 +0100 |
commit | fa831102c38c9192edf3aaf0cbcaff9ee5e006ac (patch) | |
tree | 6643f2b8d5784dd0b9571fe9a53590a2102524a5 /src/vim9type.c | |
parent | 2a71b54d35361f3f0c24db88c672b426f8acc7b7 (diff) |
patch 9.0.2163: Vim9: type can be assigned to list/dictv9.0.2163
Problem: Vim9: type can be assigned to list/dict
Solution: Prevent assigning a `type` to a `list` or `dict`
closes: #13683
Signed-off-by: Ernie Rael <errael@raelity.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/vim9type.c')
-rw-r--r-- | src/vim9type.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/vim9type.c b/src/vim9type.c index fec2bf9d3e..8840c37ccc 100644 --- a/src/vim9type.c +++ b/src/vim9type.c @@ -1660,17 +1660,16 @@ get_member_type_from_stack( // Use "unknown" for an empty list or dict. if (count == 0) return &t_unknown; - - // Use the first value type for the list member type, then find the common - // type from following items. + // Find the common type from following items. typep = ((type2_T *)stack->ga_data) + stack->ga_len; - result = (typep -(count * skip) + skip - 1)->type_curr; - for (i = 1; i < count; ++i) + result = &t_unknown; + for (i = 0; i < count; ++i) { - if (result == &t_any) - break; // won't get more common type = (typep -((count - i) * skip) + skip - 1)->type_curr; - common_type(type, result, &result, type_gap); + if (check_type_is_value(type) == FAIL) + return NULL; + if (result != &t_any) + common_type(type, result, &result, type_gap); } return result; |