Mercurial > vim
comparison src/scriptfile.c @ 22594:209c7aa56325 v8.2.1845
patch 8.2.1845: Vim9: function defined in a block can't use block variables
Commit: https://github.com/vim/vim/commit/8d739de43b84ef7817b3b5b826d1cbfe7572a62a
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Oct 14 19:39:19 2020 +0200
patch 8.2.1845: Vim9: function defined in a block can't use block variables
Problem: Vim9: function defined in a block can't use variables defined in
that block.
Solution: First step: Make a second hashtab that holds all script variables,
also block-local ones, with more information.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 14 Oct 2020 19:45:04 +0200 |
parents | 195a617b405a |
children | e82579016863 |
comparison
equal
deleted
inserted
replaced
22593:a6030e19b08f | 22594:209c7aa56325 |
---|---|
1346 di = HI2DI(hi); | 1346 di = HI2DI(hi); |
1347 di->di_flags |= DI_FLAGS_RELOAD; | 1347 di->di_flags |= DI_FLAGS_RELOAD; |
1348 } | 1348 } |
1349 } | 1349 } |
1350 | 1350 |
1351 // old imports are no longer valid | 1351 // old imports and script variables are no longer valid |
1352 free_imports(sid); | 1352 free_imports_and_script_vars(sid); |
1353 | 1353 |
1354 // in Vim9 script functions are marked deleted | 1354 // in Vim9 script functions are marked deleted |
1355 if (is_vim9) | 1355 if (is_vim9) |
1356 delete_script_functions(sid); | 1356 delete_script_functions(sid); |
1357 } | 1357 } |
1373 si->sn_version = 1; | 1373 si->sn_version = 1; |
1374 | 1374 |
1375 // Allocate the local script variables to use for this script. | 1375 // Allocate the local script variables to use for this script. |
1376 new_script_vars(script_items.ga_len); | 1376 new_script_vars(script_items.ga_len); |
1377 ga_init2(&si->sn_var_vals, sizeof(svar_T), 10); | 1377 ga_init2(&si->sn_var_vals, sizeof(svar_T), 10); |
1378 hash_init(&si->sn_all_vars.dv_hashtab); | |
1378 ga_init2(&si->sn_imports, sizeof(imported_T), 10); | 1379 ga_init2(&si->sn_imports, sizeof(imported_T), 10); |
1379 ga_init2(&si->sn_type_list, sizeof(type_T), 10); | 1380 ga_init2(&si->sn_type_list, sizeof(type_T), 10); |
1380 # ifdef FEAT_PROFILE | 1381 # ifdef FEAT_PROFILE |
1381 si->sn_prof_on = FALSE; | 1382 si->sn_prof_on = FALSE; |
1382 # endif | 1383 # endif |
1590 | 1591 |
1591 // the variables themselves are cleared in evalvars_clear() | 1592 // the variables themselves are cleared in evalvars_clear() |
1592 vim_free(si->sn_vars); | 1593 vim_free(si->sn_vars); |
1593 | 1594 |
1594 vim_free(si->sn_name); | 1595 vim_free(si->sn_name); |
1595 free_imports(i); | 1596 free_imports_and_script_vars(i); |
1596 free_string_option(si->sn_save_cpo); | 1597 free_string_option(si->sn_save_cpo); |
1597 # ifdef FEAT_PROFILE | 1598 # ifdef FEAT_PROFILE |
1598 ga_clear(&si->sn_prl_ga); | 1599 ga_clear(&si->sn_prl_ga); |
1599 # endif | 1600 # endif |
1600 vim_free(si); | 1601 vim_free(si); |