Mercurial > vim
comparison src/vim9compile.c @ 25139:7fa520b85244 v8.2.3106
patch 8.2.3106: Vim9: confusing line number reported for error
Commit: https://github.com/vim/vim/commit/6977dba04b68b91410585ada65079651788ca7dc
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jul 4 22:48:12 2021 +0200
patch 8.2.3106: Vim9: confusing line number reported for error
Problem: Vim9: confusing line number reported for error.
Solution: Use the start line number for the store instruction.
(closes #8488)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 04 Jul 2021 23:00:04 +0200 |
parents | de29f9a76233 |
children | 18b31f0a4bb5 |
comparison
equal
deleted
inserted
replaced
25138:309765b5ec40 | 25139:7fa520b85244 |
---|---|
6724 var_start = skipwhite(arg + 1); // skip over the "[" | 6724 var_start = skipwhite(arg + 1); // skip over the "[" |
6725 else | 6725 else |
6726 var_start = arg; | 6726 var_start = arg; |
6727 for (var_idx = 0; var_idx == 0 || var_idx < var_count; var_idx++) | 6727 for (var_idx = 0; var_idx == 0 || var_idx < var_count; var_idx++) |
6728 { | 6728 { |
6729 int instr_count = -1; | 6729 int instr_count = -1; |
6730 int save_lnum; | |
6730 | 6731 |
6731 if (var_start[0] == '_' && !eval_isnamec(var_start[1])) | 6732 if (var_start[0] == '_' && !eval_isnamec(var_start[1])) |
6732 { | 6733 { |
6733 // Ignore underscore in "[a, _, b] = list". | 6734 // Ignore underscore in "[a, _, b] = list". |
6734 if (var_count > 0) | 6735 if (var_count > 0) |
6977 } | 6978 } |
6978 else if (generate_two_op(cctx, op) == FAIL) | 6979 else if (generate_two_op(cctx, op) == FAIL) |
6979 goto theend; | 6980 goto theend; |
6980 } | 6981 } |
6981 | 6982 |
6983 // Use the line number of the assignment for store instruction. | |
6984 save_lnum = cctx->ctx_lnum; | |
6985 cctx->ctx_lnum = start_lnum - 1; | |
6986 | |
6982 if (lhs.lhs_has_index) | 6987 if (lhs.lhs_has_index) |
6983 { | 6988 { |
6984 // Use the info in "lhs" to store the value at the index in the | 6989 // Use the info in "lhs" to store the value at the index in the |
6985 // list or dict. | 6990 // list or dict. |
6986 if (compile_assign_unlet(var_start, &lhs, TRUE, rhs_type, cctx) | 6991 if (compile_assign_unlet(var_start, &lhs, TRUE, rhs_type, cctx) |
6987 == FAIL) | 6992 == FAIL) |
6993 { | |
6994 cctx->ctx_lnum = save_lnum; | |
6988 goto theend; | 6995 goto theend; |
6996 } | |
6989 } | 6997 } |
6990 else | 6998 else |
6991 { | 6999 { |
6992 if (is_decl && cmdidx == CMD_const && (lhs.lhs_dest == dest_script | 7000 if (is_decl && cmdidx == CMD_const && (lhs.lhs_dest == dest_script |
6993 || lhs.lhs_dest == dest_global | 7001 || lhs.lhs_dest == dest_global |
7004 // Set the type in the list or dict, so that it can be checked, | 7012 // Set the type in the list or dict, so that it can be checked, |
7005 // also in legacy script. | 7013 // also in legacy script. |
7006 generate_SETTYPE(cctx, lhs.lhs_type); | 7014 generate_SETTYPE(cctx, lhs.lhs_type); |
7007 | 7015 |
7008 if (generate_store_lhs(cctx, &lhs, instr_count) == FAIL) | 7016 if (generate_store_lhs(cctx, &lhs, instr_count) == FAIL) |
7017 { | |
7018 cctx->ctx_lnum = save_lnum; | |
7009 goto theend; | 7019 goto theend; |
7010 } | 7020 } |
7021 } | |
7022 cctx->ctx_lnum = save_lnum; | |
7011 | 7023 |
7012 if (var_idx + 1 < var_count) | 7024 if (var_idx + 1 < var_count) |
7013 var_start = skipwhite(lhs.lhs_dest_end + 1); | 7025 var_start = skipwhite(lhs.lhs_dest_end + 1); |
7014 } | 7026 } |
7015 | 7027 |