mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
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 #9535)
This commit is contained in:
@@ -2256,12 +2256,17 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
|
||||
case VAR_VOID:
|
||||
case VAR_INSTR:
|
||||
case VAR_SPECIAL: // cannot happen
|
||||
// This is skipped for local variables, they are
|
||||
// always initialized to zero.
|
||||
if (lhs.lhs_dest == dest_local)
|
||||
// This is skipped for local variables, they are always
|
||||
// initialized to zero. But in a "for" or "while" loop
|
||||
// the value may have been changed.
|
||||
if (lhs.lhs_dest == dest_local
|
||||
&& !inside_loop_scope(cctx))
|
||||
skip_store = TRUE;
|
||||
else
|
||||
{
|
||||
instr_count = instr->ga_len;
|
||||
generate_PUSHNR(cctx, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user