0
0
mirror of https://github.com/vim/vim.git synced 2025-07-04 23:07:33 -04:00

173 Commits

Author SHA1 Message Date
Yinzuo Jiang
7ccd1a2e85
patch 9.1.0524: the recursive parameter in the *_equal functions can be removed
Problem:  the recursive parameter in the *_equal functions can be removed
Solution: Remove the recursive parameter in dict_equal(), list_equal()
          object_equal and tv_equal(). Use a comparison of the static
          var recursive_cnt == 0 to determine whether or not tv_equal()
          has been called recursively (Yinzuo Jiang).

closes: #15070

Signed-off-by: Yinzuo Jiang <jiangyinzuo@foxmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-07-04 17:20:53 +02:00
Yegappan Lakshmanan
25536f415e
patch 9.1.0431: eval.c is too long
Problem:  eval.c is too long
Solution: Move garbage collection code to new gc.c file
          (Yegappan Lakshmanan)

closes: #14824

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-05-22 16:45:04 +02:00
Ernie Rael
e79e207760
patch 9.1.0027: Vim is missing a foreach() func
Problem:  Vim is missing a foreach() func
Solution: Implement foreach({expr1}, {expr2}) function,
          which applies {expr2} for each item in {expr1}
          without changing it (Ernie Rael)

closes: #12166

Signed-off-by: Ernie Rael <errael@raelity.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-01-13 11:47:33 +01:00
Ernie Rael
fa831102c3
patch 9.0.2163: Vim9: type can be assigned to list/dict
Problem:  Vim9: type can be assigned to list/dict
Solution: Prevent assigning a `type` to a `list` or `dict`

closes: #13683

Signed-off-by: Ernie Rael <errael@raelity.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-12-14 20:06:39 +01:00
Christian Brabandt
df63da98d8
patch 9.0.2123: Problem with initializing the length of range() lists
Problem:  Problem with initializing the length of range() lists
Solution: Set length explicitly when it shouldn't contain any items

range() may cause a wrong calculation of list length, which may later
then cause a segfault in list_find().  This is usually not a problem,
because range_list_materialize() calculates the length, when it
materializes the list.

In addition, in list_find() when the length of the range was wrongly
initialized, it may seem to be valid, so the check for list index
out-of-bounds will not be true, because it is called before the list is
actually materialized. And so we may eventually try to access a null
pointer, causing a segfault.

So this patch does 3 things:

- In f_range(), when we know that the list should be empty, explicitly
  set the list->lv_len value to zero. This should happen, when
  start is larger than end (in case the stride is positive) or
  end is larger than start when the stride is negative.
  This should fix the underlying issue properly. However,

- as a safety measure, let's check that the requested index is not
  out of range one more time, after the list has been materialized
  and return NULL in case it suddenly is.

- add a few more tests to verify the behaviour.

fixes: #13557
closes: #13563

Co-authored-by: Tim Pope <tpope@github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-11-23 20:14:28 +01:00
Christian Brabandt
00cb247465
patch 9.0.1876: Vim9: parsing commands with newlines wrong
Problem:  Vim9: parsing commands with newlines wrong
Solution: Accept a '\n' for parsing lists and command arguments

closes: #13015
closes: #13020

Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-09-05 20:53:46 +02:00
zeertzjq
4dd266cb66
patch 9.0.1738: Duplicate code to reverse a string
Problem:  Duplicate code to reverse a string
Solution: Move reverse_text() to strings.c and remove string_reverse().

closes: #12847

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2023-08-19 11:35:03 +02:00
zeertzjq
ad0c442f1f
patch 9.0.1723: Fix regression in {func} argument of reduce()
Problem: Fix regression in {func} argument of reduce()
Solution: pass function name as string again

Before patch 9.0.0548, passing a string as {func} argument of reduce()
is treated as a function name, but after patch 9.0.0548 it is treated as
an expression instead, which is useless as reduce() doesn't set any v:
variables. This PR restores the behavior of {func} before that patch.

Also correct an emsg() call, as e_string_list_or_blob_required doesn't
contain format specifiers.

closes: #12824

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2023-08-17 22:15:47 +02:00
zeertzjq
4f389e7c0f
patch 9.0.1722: wrong error messages when passing wrong types to count()
Problem: wrong error messages when passing wrong types to count()
Solution: fix it

This fixes two problems:
1. When passing wrong type to {ic} argument of count(), two error
   messages are given, the second of which is misleading.
2. When passing wrong type to {comp} argument of count(), the error
   message doesn't mention that {comp} may be a String.

closes: #12825

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2023-08-17 22:11:16 +02:00
Yegappan Lakshmanan
f9dc278946 patch 9.0.1540: reverse() on string doesn't work in compiled function
Problem:    reverse() on string doesn't work in compiled function.
Solution:   Accept string in argument type check. (Yegappan Lakshmanan,
            closes #12377)
2023-05-11 15:02:56 +01:00
Yegappan Lakshmanan
03ff1c2dde patch 9.0.1515: reverse() does not work for a String
Problem:    reverse() does not work for a String.
Solution:   Implement reverse() for a String. (Yegappan Lakshmanan,
            closes #12179)
2023-05-06 14:08:21 +01:00
zeertzjq
e7d49465a4 patch 9.0.1459: typo in name of type
Problem:    Typo in name of type.
Solution:   Change funccal_T to funccall_T. (closes #12265)
2023-04-16 20:53:55 +01:00
Ernie Rael
e6d40dcdc7 patch 9.0.1416: crash when collection is modified when using filter()
Problem:    Crash when collection is modified when using filter().
Solution:   Lock the list/dict/blob. (Ernie Rael, closes #12183)
2023-03-19 21:23:38 +00:00
Bram Moolenaar
be19d78c3d patch 9.0.1396: sort(list, 'N') does not work in Vim9 script context
Problem:    sort(list, 'N') does not work in Vim9 script context.
Solution:   Convert string to number without giving an error. (closes #12061)
2023-03-09 22:06:49 +00:00
Yegappan Lakshmanan
960dcbd098 patch 9.0.1391: "clear" macros are not always used
Problem:    "clear" macros are not always used.
Solution:   Use ALLOC_ONE, VIM_CLEAR, CLEAR_POINTER and CLEAR_FIELD in more
            places. (Yegappan Lakshmanan, closes #12104)
2023-03-07 17:45:11 +00:00
Yegappan Lakshmanan
e857598896 patch 9.0.1196: code is indented more than necessary
Problem:    Code is indented more than necessary.
Solution:   Use an early return where it makes sense. (Yegappan Lakshmanan,
            closes #11813)
2023-01-14 12:32:28 +00:00
Bram Moolenaar
24fe33a83a patch 9.0.0934: various code formatting issues
Problem:    Various code formatting issues.
Solution:   Improve code formatting.
2022-11-24 00:09:02 +00:00
Bram Moolenaar
82418263fa patch 9.0.0618: calling function for reduce() has too much overhead
Problem:    Calling function for reduce() has too much overhead.
Solution:   Do not create a funccall_T every time.
2022-09-28 16:16:15 +01:00
Bram Moolenaar
1936c76536 patch 9.0.0617: calling function for reduce() has too much overhead
Problem:    Calling function for reduce() has too much overhead.
Solution:   Only call clear_tv() when needed.
2022-09-28 15:19:10 +01:00
Bram Moolenaar
52df40eb04 patch 9.0.0615: using reduce() on a list from range() is a bit slow
Problem:    Using reduce() on a list from range() is a bit slow.
Solution:   Avoid materializing the list.
2022-09-28 13:22:59 +01:00
Bram Moolenaar
f1c60d4bf1 patch 9.0.0548: reduce() with a compiled lambda could be faster
Problem:    reduce() with a compiled lambda could be faster.
Solution:   Call eval_expr_typval() instead of call_func() directly.
2022-09-22 17:07:00 +01:00
Bram Moolenaar
73e28dcc61 patch 9.0.0491: no good reason to build without the float feature
Problem:    No good reason to build without the float feature.
Solution:   Remove configure check for float and "#ifdef FEAT_FLOAT".
2022-09-17 21:08:33 +01:00
Bram Moolenaar
d83392a43a patch 9.0.0345: error message for list argument could be clearer
Problem:    Error message for list argument could be clearer.
Solution:   Include the argument number. (Yegappan Lakshmanan, closes #11027)
2022-09-01 12:22:46 +01:00
Bram Moolenaar
9ba6194d4c patch 9.0.0338: return value of list_append_list() not always checked
Problem:    Return value of list_append_list() not always checked.
Solution:   Check return value and handle failure.
2022-08-31 11:25:06 +01:00
Yegappan Lakshmanan
04c4c5746e patch 9.0.0335: checks for Dictionary argument often give a vague error
Problem:    Checks for Dictionary argument often give a vague error message.
Solution:   Give a useful error message. (Yegappan Lakshmanan, closes #11009)
2022-08-30 19:48:24 +01:00
Bram Moolenaar
3e518a8ec7 patch 9.0.0331: cannot use items() on a string
Problem:    Cannot use items() on a string.
Solution:   Make items() work on a string. (closes #11016)
2022-08-30 17:45:33 +01:00
Bram Moolenaar
976f859763 patch 9.0.0327: items() does not work on a list
Problem:    items() does not work on a list. (Sergey Vlasov)
Solution:   Make items() work on a list. (closes #11013)
2022-08-30 14:34:52 +01:00
Bram Moolenaar
93a1096fe4 patch 8.2.5107: some callers of rettv_list_alloc() check for not OK
Problem:    Some callers of rettv_list_alloc() check for not OK. (Christ van
            Willegen)
Solution:   Use "==" instead of "!=" when checking the return value.
2022-06-16 11:42:09 +01:00
Yegappan Lakshmanan
ca195cc84f patch 8.2.5089: some functions return a different value on failure
Problem:    Some functions return a different value on failure.
Solution:   Initialize the return value earlier. (Yegappan Lakshmanan,
            closes #10568)
2022-06-14 13:42:26 +01:00
Bram Moolenaar
22ebd172e4 patch 8.2.4662: no error for using out of range list index
Problem:    No error for using out of range list index.
Solution:   Check list index at script level like in compiled function.
            (closes #10051)
2022-04-01 15:26:58 +01:00
Bram Moolenaar
f3980dc5d0 patch 8.2.4632: using freed memory in flatten()
Problem:    Using freed memory in flatten().
Solution:   Clear typval after recursing into list.
2022-03-26 16:42:23 +00:00
Bram Moolenaar
c6c1ec4da5 patch 8.2.4629: flattennew() makes a deep copy unnecessarily
Problem:    flattennew() makes a deep copy unnecessarily.
Solution:   Use a shallow copy. (issue #10012)
2022-03-26 10:50:11 +00:00
Bram Moolenaar
acf7d73a7f patch 8.2.4627: flatten() does not use maxdepth correctly
Problem:    flatten() does not use maxdepth correctly.
Solution:   Use a recursive implementation. (closes #10020)
2022-03-25 19:50:57 +00:00
Bram Moolenaar
2007dd49f5 patch 8.2.4455: accepting one and zero for second sort() argument is strange
Problem:    Accepting one and zero for the second sort() argument is strange.
Solution:   Disallow using one and zero in Vim9 script.
2022-02-23 13:17:47 +00:00
Bram Moolenaar
46950b225f patch 8.2.4295: Vim9: concatenating two lists may result in wrong type
Problem:    Vim9: concatenating two lists may result in wrong type.
Solution:   Remove the type instead of using list<any>. (closes #9692)
2022-02-04 11:36:51 +00:00
Bram Moolenaar
7676c15879 patch 8.2.4293: Vim9: when copying a list it gets type list<any>
Problem:    Vim9: when copying a list it gets type list<any> even when the
            original list did not have a type.
Solution:   Only set the type when the original list has a type. (closes #9692)
2022-02-03 21:47:34 +00:00
Bram Moolenaar
381692b6f1 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Problem:    Vim9: strict type checking after copy() and deepcopy().
Solution:   Allow type to change after making a copy. (closes #9644)
2022-02-02 20:01:27 +00:00
=?UTF-8?q?Dundar=20G=C3=B6c?=
d5cec1f1f0 patch 8.2.4255: theoretical computation overflow
Problem:    Theoretical computation overflow.
Solution:   Perform multiplication in a wider type. (closes #9657)
2022-01-29 15:19:23 +00:00
Bram Moolenaar
98cd30383a patch 8.2.4232: some compilers don't like a goto label without statement
Problem:    Some compilers don't like a goto label without statement.
Solution:   Return instead of using a goto.
2022-01-27 17:37:41 +00:00
Bram Moolenaar
35c807df1f patch 8.2.4231: Vim9: map() gives type error when type was not declared
Problem:    Vim9: map() gives type error when type was not declared.
Solution:   Only check the type when it was declared, like extend() does.
            (closes #9635)
2022-01-27 16:36:29 +00:00
Bram Moolenaar
04935fb17e patch 8.2.4043: using int for second argument of ga_init2()
Problem:    Using int for second argument of ga_init2().
Solution:   Remove unnessary type cast (int) when using sizeof().
2022-01-08 16:19:22 +00:00
Bram Moolenaar
d82a47dd04 patch 8.2.4012: error messages are spread out
Problem:    Error messages are spread out.
Solution:   Move the last error messages to errors.h.
2022-01-05 20:24:39 +00:00
Bram Moolenaar
a6f7929e62 patch 8.2.4005: error messages are spread out
Problem:    Error messages are spread out.
Solution:   Move more error messages to errors.h.
2022-01-04 21:30:47 +00:00
Bram Moolenaar
10d6f18b2f patch 8.2.3997: Vim9: not enough testing for extend() and map()
Problem:    Vim9: not enough testing for extend() and map().
Solution:   Add more test cases.  Fix uncovered problems.  Remove unused type
            fields.
2022-01-04 15:54:38 +00:00
Bram Moolenaar
078a46161e patch 8.2.3996: Vim9: type checking lacks information about declared type
Problem:    Vim9: type checking for list and dict lacks information about
            declared type.
Solution:   Add dv_decl_type and lv_decl_type.  Refactor the type stack to
            store two types in each entry.
2022-01-04 15:17:03 +00:00
Bram Moolenaar
ad8f248585 patch 8.2.3994: Vim9: extend() complains about type when it was not declared
Problem:    Vim9: extend() complains about the type even when it was not
            declared.
Solution:   Only check the list or dict type when it was declared.
2022-01-03 16:52:28 +00:00
Bram Moolenaar
114dbda785 patch 8.2.3991: Vim9: error when extending dict<any>
Problem:    Vim9: error when extending dict<any> with another type that it was
            initialized with.
Solution:   Also set the type for dict<any> if the initializer has a more
            specific type. (closes #9461)
2022-01-03 12:28:03 +00:00
Bram Moolenaar
3a846e6bca patch 8.2.3972: error messages are spread out
Problem:    Error messages are spread out.
Solution:   Move the last errors from globals.h to errors.h.
2022-01-01 16:21:00 +00:00
Bram Moolenaar
460ae5dfca patch 8.2.3967: error messages are spread out
Problem:    Error messages are spread out.
Solution:   Move more errors to errors.h.
2022-01-01 14:19:49 +00:00
Bram Moolenaar
436b5adc97 patch 8.2.3961: error messages are spread out
Problem:    Error messages are spread out.
Solution:   Move more errors to errors.h.
2021-12-31 22:49:24 +00:00