Mercurial > vim
comparison src/vim9compile.c @ 19623:2fee087c94cb v8.2.0368
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Commit: https://github.com/vim/vim/commit/5269bd2a724fdb8c16c9635ef744a670f1bc8bd5
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Mar 9 19:25:27 2020 +0100
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Problem: Vim9: import that redefines local variable does not fail.
Solution: Check for already defined symbols.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 09 Mar 2020 19:30:04 +0100 |
parents | 1098989a90ee |
children | ad37a198a708 |
comparison
equal
deleted
inserted
replaced
19622:684f747f0568 | 19623:2fee087c94cb |
---|---|
199 cc = name[len]; | 199 cc = name[len]; |
200 name[len] = NUL; | 200 name[len] = NUL; |
201 di = find_var_in_ht(ht, 0, name, TRUE); | 201 di = find_var_in_ht(ht, 0, name, TRUE); |
202 name[len] = cc; | 202 name[len] = cc; |
203 return di == NULL ? FAIL: OK; | 203 return di == NULL ? FAIL: OK; |
204 } | |
205 | |
206 /* | |
207 * Check if "p[len]" is already defined, either in script "import_sid" or in | |
208 * compilation context "cctx". | |
209 * Return FAIL and give an error if it defined. | |
210 */ | |
211 int | |
212 check_defined(char_u *p, int len, cctx_T *cctx) | |
213 { | |
214 if (lookup_script(p, len) == OK | |
215 || (cctx != NULL | |
216 && (lookup_local(p, len, cctx) >= 0 | |
217 || find_imported(p, len, cctx) != NULL))) | |
218 { | |
219 semsg("E1073: imported name already defined: %s", p); | |
220 return FAIL; | |
221 } | |
222 return OK; | |
204 } | 223 } |
205 | 224 |
206 static type_T * | 225 static type_T * |
207 get_list_type(type_T *member_type, garray_T *type_list) | 226 get_list_type(type_T *member_type, garray_T *type_list) |
208 { | 227 { |
3810 * Compile an :import command. | 3829 * Compile an :import command. |
3811 */ | 3830 */ |
3812 static char_u * | 3831 static char_u * |
3813 compile_import(char_u *arg, cctx_T *cctx) | 3832 compile_import(char_u *arg, cctx_T *cctx) |
3814 { | 3833 { |
3815 return handle_import(arg, &cctx->ctx_imports, 0); | 3834 return handle_import(arg, &cctx->ctx_imports, 0, cctx); |
3816 } | 3835 } |
3817 | 3836 |
3818 /* | 3837 /* |
3819 * generate a jump to the ":endif"/":endfor"/":endwhile"/":finally"/":endtry". | 3838 * generate a jump to the ":endif"/":endfor"/":endwhile"/":finally"/":endtry". |
3820 */ | 3839 */ |