@@ -5384,14 +5384,14 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
53845384 member_type = type ;
53855385 if (var_end > var_start + varlen )
53865386 {
5387- // Something follows after the variable: "var[idx]".
5387+ // Something follows after the variable: "var[idx]" or "var.key" .
53885388 if (is_decl )
53895389 {
53905390 emsg (_ (e_cannot_use_index_when_declaring_variable ));
53915391 goto theend ;
53925392 }
53935393
5394- if (var_start [varlen ] == '[' )
5394+ if (var_start [varlen ] == '[' || var_start [ varlen ] == '.' )
53955395 {
53965396 has_index = TRUE;
53975397 if (type -> tt_member == NULL )
@@ -5635,21 +5635,33 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
56355635 {
56365636 int r ;
56375637
5638- // Compile the "idx" in "var[idx]".
5638+ // Compile the "idx" in "var[idx]" or "key" in "var.key" .
56395639 if (new_local )
56405640 -- cctx -> ctx_locals .ga_len ;
5641- p = skipwhite (var_start + varlen + 1 );
5642- r = compile_expr0 (& p , cctx );
5641+ p = var_start + varlen ;
5642+ if (* p == '[' )
5643+ {
5644+ p = skipwhite (p + 1 );
5645+ r = compile_expr0 (& p , cctx );
5646+ if (r == OK && * skipwhite (p ) != ']' )
5647+ {
5648+ // this should not happen
5649+ emsg (_ (e_missbrac ));
5650+ r = FAIL ;
5651+ }
5652+ }
5653+ else // if (*p == '.')
5654+ {
5655+ char_u * key_end = to_name_end (p + 1 , TRUE);
5656+ char_u * key = vim_strnsave (p + 1 , key_end - p - 1 );
5657+
5658+ r = generate_PUSHS (cctx , key );
5659+ }
56435660 if (new_local )
56445661 ++ cctx -> ctx_locals .ga_len ;
56455662 if (r == FAIL )
56465663 goto theend ;
5647- if (* skipwhite (p ) != ']' )
5648- {
5649- // this should not happen
5650- emsg (_ (e_missbrac ));
5651- goto theend ;
5652- }
5664+
56535665 if (type == & t_any )
56545666 {
56555667 type_T * idx_type = ((type_T * * )stack -> ga_data )[
0 commit comments