Mercurial > vim
comparison src/eval.c @ 15762:dff66c4670b1 v8.1.0888
patch 8.1.0888: the a: dict is not immutable as documented
commit https://github.com/vim/vim/commit/31b816042fca879b11965ddd75287732563ba698
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Feb 10 22:14:27 2019 +0100
patch 8.1.0888: the a: dict is not immutable as documented
Problem: The a: dict is not immutable as documented.
Solution: Make the a:dict immutable, add a test. (Ozaki Kiichi, Yasuhiro
Matsumoto, closes #3929)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 10 Feb 2019 22:15:05 +0100 |
parents | 6f1c7e9a6393 |
children | 77e97f159554 |
comparison
equal
deleted
inserted
replaced
15761:e2d967c0caf5 | 15762:dff66c4670b1 |
---|---|
2090 return NULL; | 2090 return NULL; |
2091 } | 2091 } |
2092 | 2092 |
2093 if (lp->ll_di == NULL) | 2093 if (lp->ll_di == NULL) |
2094 { | 2094 { |
2095 /* Can't add "v:" variable. */ | 2095 // Can't add "v:" or "a:" variable. |
2096 if (lp->ll_dict == &vimvardict) | 2096 if (lp->ll_dict == &vimvardict |
2097 || &lp->ll_dict->dv_hashtab == get_funccal_args_ht()) | |
2097 { | 2098 { |
2098 semsg(_(e_illvar), name); | 2099 semsg(_(e_illvar), name); |
2099 return NULL; | 2100 return NULL; |
2100 } | 2101 } |
2101 | 2102 |
2102 /* Key does not exist in dict: may need to add it. */ | 2103 // Key does not exist in dict: may need to add it. |
2103 if (*p == '[' || *p == '.' || unlet) | 2104 if (*p == '[' || *p == '.' || unlet) |
2104 { | 2105 { |
2105 if (!quiet) | 2106 if (!quiet) |
2106 semsg(_(e_dictkey), key); | 2107 semsg(_(e_dictkey), key); |
2107 clear_tv(&var1); | 2108 clear_tv(&var1); |
7917 | 7918 |
7918 clear_tv(&v->di_tv); | 7919 clear_tv(&v->di_tv); |
7919 } | 7920 } |
7920 else /* add a new variable */ | 7921 else /* add a new variable */ |
7921 { | 7922 { |
7922 /* Can't add "v:" variable. */ | 7923 // Can't add "v:" or "a:" variable. |
7923 if (ht == &vimvarht) | 7924 if (ht == &vimvarht || ht == get_funccal_args_ht()) |
7924 { | 7925 { |
7925 semsg(_(e_illvar), name); | 7926 semsg(_(e_illvar), name); |
7926 return; | 7927 return; |
7927 } | 7928 } |
7928 | 7929 |
7929 /* Make sure the variable name is valid. */ | 7930 // Make sure the variable name is valid. |
7930 if (!valid_varname(varname)) | 7931 if (!valid_varname(varname)) |
7931 return; | 7932 return; |
7932 | 7933 |
7933 v = (dictitem_T *)alloc((unsigned)(sizeof(dictitem_T) | 7934 v = (dictitem_T *)alloc((unsigned)(sizeof(dictitem_T) |
7934 + STRLEN(varname))); | 7935 + STRLEN(varname))); |