comparison src/vim9compile.c @ 27148:6ed31017c303 v8.2.4103

patch 8.2.4103: Vim9: variable declared in for loop not initialzed Commit: https://github.com/vim/vim/commit/38ecd9722664049d636f4fba759b3ebbfd34e97d Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 15 21:44:44 2022 +0000 patch 8.2.4103: Vim9: variable declared in for loop not initialzed Problem: Vim9: variable declared in for loop not initialzed. Solution: Always initialze the variable. (closes https://github.com/vim/vim/issues/9535)
author Bram Moolenaar <Bram@vim.org>
date Sat, 15 Jan 2022 22:45:03 +0100
parents 0e88b48575ee
children 44cb142c8615
comparison
equal deleted inserted replaced
27147:bcaefb769725 27148:6ed31017c303
2254 case VAR_ANY: 2254 case VAR_ANY:
2255 case VAR_PARTIAL: 2255 case VAR_PARTIAL:
2256 case VAR_VOID: 2256 case VAR_VOID:
2257 case VAR_INSTR: 2257 case VAR_INSTR:
2258 case VAR_SPECIAL: // cannot happen 2258 case VAR_SPECIAL: // cannot happen
2259 // This is skipped for local variables, they are 2259 // This is skipped for local variables, they are always
2260 // always initialized to zero. 2260 // initialized to zero. But in a "for" or "while" loop
2261 if (lhs.lhs_dest == dest_local) 2261 // the value may have been changed.
2262 if (lhs.lhs_dest == dest_local
2263 && !inside_loop_scope(cctx))
2262 skip_store = TRUE; 2264 skip_store = TRUE;
2263 else 2265 else
2266 {
2267 instr_count = instr->ga_len;
2264 generate_PUSHNR(cctx, 0); 2268 generate_PUSHNR(cctx, 0);
2269 }
2265 break; 2270 break;
2266 } 2271 }
2267 } 2272 }
2268 if (var_count == 0) 2273 if (var_count == 0)
2269 end = p; 2274 end = p;