# HG changeset patch # User Bram Moolenaar # Date 1638224104 -3600 # Node ID 4044306e3836d618bdec881174644a6c74e5d8b8 # Parent 37959db258e52a2a95312add71171bd05865268f patch 8.2.3701: Vim9: invalid LHS is not possible Commit: https://github.com/vim/vim/commit/c750d91a07ace532e993349aa5c13dda5c888cc0 Author: Bram Moolenaar Date: Mon Nov 29 22:02:12 2021 +0000 patch 8.2.3701: Vim9: invalid LHS is not possible Problem: Vim9: invalid LHS is not possible. Solution: Remove unreachable error message. diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -754,6 +754,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3701, +/**/ 3700, /**/ 3699, diff --git a/src/vim9compile.c b/src/vim9compile.c --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -6503,52 +6503,43 @@ compile_lhs( lhs->lhs_member_type = lhs->lhs_type; if (lhs->lhs_has_index) { + char_u *after = var_start + lhs->lhs_varlen; + char_u *p; + // Something follows after the variable: "var[idx]" or "var.key". - // TODO: should we also handle "->func()" here? if (is_decl) { emsg(_(e_cannot_use_index_when_declaring_variable)); return FAIL; } - if (var_start[lhs->lhs_varlen] == '[' - || var_start[lhs->lhs_varlen] == '.') - { - char_u *after = var_start + lhs->lhs_varlen; - char_u *p; - - // Only the last index is used below, if there are others - // before it generate code for the expression. Thus for - // "ll[1][2]" the expression is "ll[1]" and "[2]" is the index. - for (;;) - { - p = skip_index(after); - if (*p != '[' && *p != '.') - { - lhs->lhs_varlen_total = p - var_start; - break; - } - after = p; - } - if (after > var_start + lhs->lhs_varlen) - { - lhs->lhs_varlen = after - var_start; - lhs->lhs_dest = dest_expr; - // We don't know the type before evaluating the expression, - // use "any" until then. - lhs->lhs_type = &t_any; - } - - if (lhs->lhs_type->tt_member == NULL) - lhs->lhs_member_type = &t_any; - else - lhs->lhs_member_type = lhs->lhs_type->tt_member; - } + // Now: var_start[lhs->lhs_varlen] is '[' or '.' + // Only the last index is used below, if there are others + // before it generate code for the expression. Thus for + // "ll[1][2]" the expression is "ll[1]" and "[2]" is the index. + for (;;) + { + p = skip_index(after); + if (*p != '[' && *p != '.') + { + lhs->lhs_varlen_total = p - var_start; + break; + } + after = p; + } + if (after > var_start + lhs->lhs_varlen) + { + lhs->lhs_varlen = after - var_start; + lhs->lhs_dest = dest_expr; + // We don't know the type before evaluating the expression, + // use "any" until then. + lhs->lhs_type = &t_any; + } + + if (lhs->lhs_type->tt_member == NULL) + lhs->lhs_member_type = &t_any; else - { - semsg("Not supported yet: %s", var_start); - return FAIL; - } + lhs->lhs_member_type = lhs->lhs_type->tt_member; } return OK; }