diff src/list.c @ 32417:3c2c1cb61004 v9.0.1540

patch 9.0.1540: reverse() on string doesn't work in compiled function Commit: https://github.com/vim/vim/commit/f9dc278946d52235a0025fd347bd9ff571258470 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Thu May 11 15:02:56 2023 +0100 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)
author Bram Moolenaar <Bram@vim.org>
date Thu, 11 May 2023 16:15:08 +0200
parents d5e673b941cd
children 448aef880252
line wrap: on
line diff
--- a/src/list.c
+++ b/src/list.c
@@ -2994,16 +2994,14 @@ list_reverse(list_T *l, typval_T *rettv)
     void
 f_reverse(typval_T *argvars, typval_T *rettv)
 {
-    if (in_vim9script() && check_for_list_or_blob_arg(argvars, 0) == FAIL)
+    if (check_for_string_or_list_or_blob_arg(argvars, 0) == FAIL)
 	return;
 
     if (argvars[0].v_type == VAR_BLOB)
 	blob_reverse(argvars[0].vval.v_blob, rettv);
     else if (argvars[0].v_type == VAR_STRING)
 	string_reverse(argvars[0].vval.v_string, rettv);
-    else if (argvars[0].v_type != VAR_LIST)
-	semsg(_(e_argument_of_str_must_be_list_or_blob), "reverse()");
-    else
+    else if (argvars[0].v_type == VAR_LIST)
 	list_reverse(argvars[0].vval.v_list, rettv);
 }