comparison src/vim9type.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 029c59bf78f1
children f1010a0e6226
comparison
equal deleted inserted replaced
30575:3b314751334b 30576:72e6073a2822
41 { 41 {
42 ((type_T **)type_gap->ga_data)[type_gap->ga_len] = type; 42 ((type_T **)type_gap->ga_data)[type_gap->ga_len] = type;
43 ++type_gap->ga_len; 43 ++type_gap->ga_len;
44 } 44 }
45 return type; 45 return type;
46 }
47
48 /*
49 * Make a shallow copy of "type".
50 * When allocation fails returns "type".
51 */
52 type_T *
53 copy_type(type_T *type, garray_T *type_gap)
54 {
55 type_T *copy = get_type_ptr(type_gap);
56
57 if (copy == NULL)
58 return type;
59 *copy = *type;
60
61 if (type->tt_args != NULL)
62 {
63 copy->tt_args = ALLOC_MULT(type_T *, type->tt_argcount);
64 if (copy->tt_args != NULL)
65 for (int i = 0; i < type->tt_argcount; ++i)
66 copy->tt_args[i] = type->tt_args[i];
67 }
68
69 return copy;
46 } 70 }
47 71
48 void 72 void
49 clear_type_list(garray_T *gap) 73 clear_type_list(garray_T *gap)
50 { 74 {