diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-09-29 19:14:42 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-09-29 19:14:42 +0100 |
commit | fa1039760e8c1a0c7a2a722160bd3d71a4736e61 (patch) | |
tree | 3749fc4f1e8e0cdccdde2c131dfca30b3b07917c /src/vim9instr.c | |
parent | 9f573a8df02d9f699a43d2afbd1d2841d700b9ad (diff) |
patch 9.0.0623: error for modifying a const is not detected at compile timev9.0.0623
Problem: Error for modifying a const is not detected at compile time.
Solution: Add TTFLAG_CONST and check for it in add() and extend().
Diffstat (limited to 'src/vim9instr.c')
-rw-r--r-- | src/vim9instr.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/vim9instr.c b/src/vim9instr.c index 85a49a8934..18dad11688 100644 --- a/src/vim9instr.c +++ b/src/vim9instr.c @@ -1533,6 +1533,8 @@ generate_LISTAPPEND(cctx_T *cctx) // For checking the item type we use the declared type of the list and the // current type of the added item, adding a string to [1, 2] is OK. list_type = get_decl_type_on_stack(cctx, 1); + if (arg_type_modifiable(list_type, 1) == FAIL) + return FAIL; item_type = get_type_on_stack(cctx, 0); expected = list_type->tt_member; if (need_type(item_type, expected, -1, 0, cctx, FALSE, FALSE) == FAIL) @@ -1554,7 +1556,9 @@ generate_BLOBAPPEND(cctx_T *cctx) { type_T *item_type; - // Caller already checked that blob_type is a blob. + // Caller already checked that blob_type is a blob, check it is modifiable. + if (arg_type_modifiable(get_decl_type_on_stack(cctx, 1), 1) == FAIL) + return FAIL; item_type = get_type_on_stack(cctx, 0); if (need_type(item_type, &t_number, -1, 0, cctx, FALSE, FALSE) == FAIL) return FAIL; |