Mercurial > vim
comparison src/vim9compile.c @ 26340:4044306e3836 v8.2.3701
patch 8.2.3701: Vim9: invalid LHS is not possible
Commit: https://github.com/vim/vim/commit/c750d91a07ace532e993349aa5c13dda5c888cc0
Author: Bram Moolenaar <Bram@vim.org>
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 29 Nov 2021 23:15:04 +0100 |
parents | 3841da4eac23 |
children | 8be6413a8e27 |
comparison
equal
deleted
inserted
replaced
26339:37959db258e5 | 26340:4044306e3836 |
---|---|
6501 } | 6501 } |
6502 | 6502 |
6503 lhs->lhs_member_type = lhs->lhs_type; | 6503 lhs->lhs_member_type = lhs->lhs_type; |
6504 if (lhs->lhs_has_index) | 6504 if (lhs->lhs_has_index) |
6505 { | 6505 { |
6506 char_u *after = var_start + lhs->lhs_varlen; | |
6507 char_u *p; | |
6508 | |
6506 // Something follows after the variable: "var[idx]" or "var.key". | 6509 // Something follows after the variable: "var[idx]" or "var.key". |
6507 // TODO: should we also handle "->func()" here? | |
6508 if (is_decl) | 6510 if (is_decl) |
6509 { | 6511 { |
6510 emsg(_(e_cannot_use_index_when_declaring_variable)); | 6512 emsg(_(e_cannot_use_index_when_declaring_variable)); |
6511 return FAIL; | 6513 return FAIL; |
6512 } | 6514 } |
6513 | 6515 |
6514 if (var_start[lhs->lhs_varlen] == '[' | 6516 // Now: var_start[lhs->lhs_varlen] is '[' or '.' |
6515 || var_start[lhs->lhs_varlen] == '.') | 6517 // Only the last index is used below, if there are others |
6516 { | 6518 // before it generate code for the expression. Thus for |
6517 char_u *after = var_start + lhs->lhs_varlen; | 6519 // "ll[1][2]" the expression is "ll[1]" and "[2]" is the index. |
6518 char_u *p; | 6520 for (;;) |
6519 | 6521 { |
6520 // Only the last index is used below, if there are others | 6522 p = skip_index(after); |
6521 // before it generate code for the expression. Thus for | 6523 if (*p != '[' && *p != '.') |
6522 // "ll[1][2]" the expression is "ll[1]" and "[2]" is the index. | 6524 { |
6523 for (;;) | 6525 lhs->lhs_varlen_total = p - var_start; |
6524 { | 6526 break; |
6525 p = skip_index(after); | 6527 } |
6526 if (*p != '[' && *p != '.') | 6528 after = p; |
6527 { | 6529 } |
6528 lhs->lhs_varlen_total = p - var_start; | 6530 if (after > var_start + lhs->lhs_varlen) |
6529 break; | 6531 { |
6530 } | 6532 lhs->lhs_varlen = after - var_start; |
6531 after = p; | 6533 lhs->lhs_dest = dest_expr; |
6532 } | 6534 // We don't know the type before evaluating the expression, |
6533 if (after > var_start + lhs->lhs_varlen) | 6535 // use "any" until then. |
6534 { | 6536 lhs->lhs_type = &t_any; |
6535 lhs->lhs_varlen = after - var_start; | 6537 } |
6536 lhs->lhs_dest = dest_expr; | 6538 |
6537 // We don't know the type before evaluating the expression, | 6539 if (lhs->lhs_type->tt_member == NULL) |
6538 // use "any" until then. | 6540 lhs->lhs_member_type = &t_any; |
6539 lhs->lhs_type = &t_any; | |
6540 } | |
6541 | |
6542 if (lhs->lhs_type->tt_member == NULL) | |
6543 lhs->lhs_member_type = &t_any; | |
6544 else | |
6545 lhs->lhs_member_type = lhs->lhs_type->tt_member; | |
6546 } | |
6547 else | 6541 else |
6548 { | 6542 lhs->lhs_member_type = lhs->lhs_type->tt_member; |
6549 semsg("Not supported yet: %s", var_start); | |
6550 return FAIL; | |
6551 } | |
6552 } | 6543 } |
6553 return OK; | 6544 return OK; |
6554 } | 6545 } |
6555 | 6546 |
6556 /* | 6547 /* |