Problem: Vim9: assignment not recognized if declaration was skipped.
Solution: Also recognized an assignment if the variable does not exist.
(closes #8108)
// Recognize an assignment if we recognize the variable name:
// "g:var = expr"
- // "var = expr" where "var" is a variable name.
+ // "var = expr" where "var" is a variable name or we are skipping
+ // (variable declaration might have been skipped).
if (*eap->cmd == '@')
p = eap->cmd + 2;
oplen = assignment_len(skipwhite(p), &heredoc);
|| *eap->cmd == '&'
|| *eap->cmd == '$'
|| *eap->cmd == '@'
+ || eap->skip
|| lookup(eap->cmd, p - eap->cmd, TRUE, cctx) == OK)
{
eap->cmdidx = CMD_var;
END
enddef
+def Test_skipped_assignment()
+ var lines =<< trim END
+ for x in []
+ var i: number = 1
+ while false
+ i += 1
+ endwhile
+ endfor
+ END
+ CheckDefAndScriptSuccess(lines)
+enddef
+
def Test_assign_unpack()
var lines =<< trim END
var v1: number
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 2771,
/**/
2770,
/**/