Mercurial > vim
comparison src/vim9instr.c @ 30576:72e6073a2822 v9.0.0623
patch 9.0.0623: error for modifying a const is not detected at compile time
Commit: https://github.com/vim/vim/commit/fa1039760e8c1a0c7a2a722160bd3d71a4736e61
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Sep 29 19:14:42 2022 +0100
patch 9.0.0623: error for modifying a const is not detected at compile time
Problem: Error for modifying a const is not detected at compile time.
Solution: Add TTFLAG_CONST and check for it in add() and extend().
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 29 Sep 2022 20:15:05 +0200 |
parents | fc0830246f49 |
children | d914a3812d5b |
comparison
equal
deleted
inserted
replaced
30575:3b314751334b | 30576:72e6073a2822 |
---|---|
1531 | 1531 |
1532 // Caller already checked that list_type is a list. | 1532 // Caller already checked that list_type is a list. |
1533 // For checking the item type we use the declared type of the list and the | 1533 // For checking the item type we use the declared type of the list and the |
1534 // current type of the added item, adding a string to [1, 2] is OK. | 1534 // current type of the added item, adding a string to [1, 2] is OK. |
1535 list_type = get_decl_type_on_stack(cctx, 1); | 1535 list_type = get_decl_type_on_stack(cctx, 1); |
1536 if (arg_type_modifiable(list_type, 1) == FAIL) | |
1537 return FAIL; | |
1536 item_type = get_type_on_stack(cctx, 0); | 1538 item_type = get_type_on_stack(cctx, 0); |
1537 expected = list_type->tt_member; | 1539 expected = list_type->tt_member; |
1538 if (need_type(item_type, expected, -1, 0, cctx, FALSE, FALSE) == FAIL) | 1540 if (need_type(item_type, expected, -1, 0, cctx, FALSE, FALSE) == FAIL) |
1539 return FAIL; | 1541 return FAIL; |
1540 | 1542 |
1552 int | 1554 int |
1553 generate_BLOBAPPEND(cctx_T *cctx) | 1555 generate_BLOBAPPEND(cctx_T *cctx) |
1554 { | 1556 { |
1555 type_T *item_type; | 1557 type_T *item_type; |
1556 | 1558 |
1557 // Caller already checked that blob_type is a blob. | 1559 // Caller already checked that blob_type is a blob, check it is modifiable. |
1560 if (arg_type_modifiable(get_decl_type_on_stack(cctx, 1), 1) == FAIL) | |
1561 return FAIL; | |
1558 item_type = get_type_on_stack(cctx, 0); | 1562 item_type = get_type_on_stack(cctx, 0); |
1559 if (need_type(item_type, &t_number, -1, 0, cctx, FALSE, FALSE) == FAIL) | 1563 if (need_type(item_type, &t_number, -1, 0, cctx, FALSE, FALSE) == FAIL) |
1560 return FAIL; | 1564 return FAIL; |
1561 | 1565 |
1562 if (generate_instr(cctx, ISN_BLOBAPPEND) == NULL) | 1566 if (generate_instr(cctx, ISN_BLOBAPPEND) == NULL) |