Mercurial > vim
diff 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 |
line wrap: on
line diff
--- a/src/vim9type.c +++ b/src/vim9type.c @@ -45,6 +45,30 @@ get_type_ptr(garray_T *type_gap) return type; } +/* + * Make a shallow copy of "type". + * When allocation fails returns "type". + */ + type_T * +copy_type(type_T *type, garray_T *type_gap) +{ + type_T *copy = get_type_ptr(type_gap); + + if (copy == NULL) + return type; + *copy = *type; + + if (type->tt_args != NULL) + { + copy->tt_args = ALLOC_MULT(type_T *, type->tt_argcount); + if (copy->tt_args != NULL) + for (int i = 0; i < type->tt_argcount; ++i) + copy->tt_args[i] = type->tt_args[i]; + } + + return copy; +} + void clear_type_list(garray_T *gap) {