To: vim_dev@googlegroups.com Subject: Patch 8.2.4383 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4383 Problem: Vim9: unused code lines. Solution: Rely on either "cctx" or "cstack" to not be NULL. Files: src/vim9compile.c *** ../vim-8.2.4382/src/vim9compile.c 2022-02-13 21:51:02.388484128 +0000 --- src/vim9compile.c 2022-02-14 19:43:12.220861313 +0000 *************** *** 151,158 **** /* * Lookup a script-local variable in the current script, possibly defined in a * block that contains the function "cctx->ctx_ufunc". ! * "cctx" is NULL at the script level. ! * "cstack_T" is NULL in a function. * If "len" is <= 0 "name" must be NUL terminated. * Return NULL when not found. */ --- 151,157 ---- /* * Lookup a script-local variable in the current script, possibly defined in a * block that contains the function "cctx->ctx_ufunc". ! * "cctx" is NULL at the script level, "cstack" is NULL in a function. * If "len" is <= 0 "name" must be NUL terminated. * Return NULL when not found. */ *************** *** 185,205 **** if (cctx == NULL) { // Not in a function scope, find variable with block ID equal to or ! // smaller than the current block id. If "cstack" is not NULL go up ! // the block scopes (more accurate). while (sav != NULL) { ! if (cstack != NULL) ! { ! int idx; ! ! for (idx = cstack->cs_idx; idx >= 0; --idx) ! if (cstack->cs_block_id[idx] == sav->sav_block_id) ! break; ! if (idx >= 0) break; ! } ! else if (sav->sav_block_id <= si->sn_current_block_id) break; sav = sav->sav_next; } --- 184,199 ---- if (cctx == NULL) { // Not in a function scope, find variable with block ID equal to or ! // smaller than the current block id. Use "cstack" to go up the block ! // scopes. while (sav != NULL) { ! int idx; ! ! for (idx = cstack->cs_idx; idx >= 0; --idx) ! if (cstack->cs_block_id[idx] == sav->sav_block_id) break; ! if (idx >= 0) break; sav = sav->sav_next; } *************** *** 236,243 **** /* * Lookup a variable (without s: prefix) in the current script. ! * "cctx" is NULL at the script level. ! * "cstack" is NULL in a function. * Returns OK or FAIL. */ int --- 230,236 ---- /* * Lookup a variable (without s: prefix) in the current script. ! * "cctx" is NULL at the script level, "cstack" is NULL in a function. * Returns OK or FAIL. */ int *************** *** 296,302 **** /* * Check if "p[len]" is already defined, either in script "import_sid" or in ! * compilation context "cctx". "cctx" is NULL at the script level. * Does not check the global namespace. * If "is_arg" is TRUE the error message is for an argument name. * Return FAIL and give an error if it defined. --- 289,296 ---- /* * Check if "p[len]" is already defined, either in script "import_sid" or in ! * compilation context "cctx". ! * "cctx" is NULL at the script level, "cstack" is NULL in a function. * Does not check the global namespace. * If "is_arg" is TRUE the error message is for an argument name. * Return FAIL and give an error if it defined. *************** *** 507,512 **** --- 501,507 ---- /* * Find "name" in script-local items of script "sid". * Pass "check_writable" to check_item_writable(). + * "cctx" is NULL at the script level, "cstack" is NULL in a function. * Returns the index in "sn_var_vals" if found. * If found but not in "sn_var_vals" returns -1. * If not found or the variable is not writable returns -2. *** ../vim-8.2.4382/src/version.c 2022-02-14 19:17:25.220143635 +0000 --- src/version.c 2022-02-14 19:40:11.845244099 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4383, /**/ -- Don't read everything you believe. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///