]> granicus.if.org Git - vim/commitdiff
patch 8.2.0334: abort called when using test_void() v8.2.0334
authorBram Moolenaar <Bram@vim.org>
Sat, 29 Feb 2020 16:38:12 +0000 (17:38 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 29 Feb 2020 16:38:12 +0000 (17:38 +0100)
Problem:    Abort called when using test_void(). (Dominique Pelle)
Solution:   Only give an error, don't abort.

src/eval.c
src/evalfunc.c
src/json.c
src/message.c
src/proto/message.pro
src/testdir/test_functions.vim
src/version.c

index dcaf2f02cc768ffb5588474ce7e82b5c161c14ba..c81ece14942792ff65b6bcfd322bf674f0dcc393 100644 (file)
@@ -5560,7 +5560,7 @@ tv_get_number_chk(typval_T *varp, int *denote)
            break;
        case VAR_UNKNOWN:
        case VAR_VOID:
-           internal_error("tv_get_number(UNKNOWN)");
+           internal_error_no_abort("tv_get_number(UNKNOWN)");
            break;
     }
     if (denote == NULL)                // useful for values that must be unsigned
@@ -5614,7 +5614,7 @@ tv_get_float(typval_T *varp)
            break;
        case VAR_UNKNOWN:
        case VAR_VOID:
-           internal_error("tv_get_float(UNKNOWN)");
+           internal_error_no_abort("tv_get_float(UNKNOWN)");
            break;
     }
     return 0;
@@ -5886,7 +5886,7 @@ copy_tv(typval_T *from, typval_T *to)
            break;
        case VAR_UNKNOWN:
        case VAR_VOID:
-           internal_error("copy_tv(UNKNOWN)");
+           internal_error_no_abort("copy_tv(UNKNOWN)");
            break;
     }
 }
@@ -5965,7 +5965,7 @@ item_copy(
            break;
        case VAR_UNKNOWN:
        case VAR_VOID:
-           internal_error("item_copy(UNKNOWN)");
+           internal_error_no_abort("item_copy(UNKNOWN)");
            ret = FAIL;
     }
     --recurse;
index 3fce946bf13da7796428a250557acdc383378556..39e347ad209e91d14d57ff00e088bd5e77c16386 100644 (file)
@@ -1890,10 +1890,7 @@ f_empty(typval_T *argvars, typval_T *rettv)
 #endif
        case VAR_UNKNOWN:
        case VAR_VOID:
-           // Let's not use internal_error() here, otherwise
-           // empty(test_unknown()) with ABORT_ON_INTERNAL_ERROR defined makes
-           // Vim abort.
-           semsg(_(e_intern2), "f_empty(UNKNOWN)");
+           internal_error_no_abort("f_empty(UNKNOWN)");
            n = TRUE;
            break;
     }
@@ -8278,10 +8275,7 @@ f_type(typval_T *argvars, typval_T *rettv)
        case VAR_BLOB:    n = VAR_TYPE_BLOB; break;
        case VAR_UNKNOWN:
        case VAR_VOID:
-            // Let's not use internal_error() here, otherwise
-            // empty(test_unknown()) with ABORT_ON_INTERNAL_ERROR defined
-            // makes Vim abort.
-            semsg(_(e_intern2), "f_type(UNKNOWN)");
+            internal_error_no_abort("f_type(UNKNOWN)");
             n = -1;
             break;
     }
index d5e5782c5203420512e00bad85c1fa0961d66aca..f4a03e61ad6771cb7690c1ac5f2adfb5426cf007 100644 (file)
@@ -352,7 +352,7 @@ json_encode_item(garray_T *gap, typval_T *val, int copyID, int options)
 #endif
        case VAR_UNKNOWN:
        case VAR_VOID:
-           internal_error("json_encode_item()");
+           internal_error_no_abort("json_encode_item()");
            return FAIL;
     }
     return OK;
index c2855fb34b0f5852591b700cca5eb99d10720c50..cb1a773ce7602d801cf0e56e22a2461aebfc6916 100644 (file)
@@ -838,6 +838,16 @@ internal_error(char *where)
     siemsg(_(e_intern2), where);
 }
 
+/*
+ * Like internal_error() but do not call abort(), to avoid tests using
+ * test_unknown() and test_void() causing Vim to exit.
+ */
+    void
+internal_error_no_abort(char *where)
+{
+     semsg(_(e_intern2), where);
+}
+
 // emsg3() and emsgn() are in misc2.c to avoid warnings for the prototypes.
 
     void
index 5c9ca6cb11abfb3a3ba2d6341d612200b55745ab..16c33548406133f88f4d45100c04b014b5147fdc 100644 (file)
@@ -12,6 +12,7 @@ void do_perror(char *msg);
 int emsg(char *s);
 void iemsg(char *s);
 void internal_error(char *where);
+void internal_error_no_abort(char *where);
 void emsg_invreg(int name);
 void emsg_namelen(char *msg, char_u *name, int len);
 char *msg_trunc_attr(char *s, int force, int attr);
index 6f3b81a30c1868b57c601878636e1432398b4465..ef4180a7709935aae21b16e22d8fd75a1d6e9e4c 100644 (file)
@@ -63,6 +63,16 @@ func Test_empty()
   call assert_fails("call empty(test_unknown())", 'E685:')
 endfunc
 
+func Test_test_void()
+  call assert_fails('echo 1 == test_void()', 'E685:')
+  if has('float')
+    call assert_fails('echo 1.0 == test_void()', 'E685:')
+  endif
+  call assert_fails('let x = json_encode(test_void())', 'E685:')
+  call assert_fails('let x = copy(test_void())', 'E685:')
+  call assert_fails('let x = copy([test_void()])', 'E685:')
+endfunc
+
 func Test_len()
   call assert_equal(1, len(0))
   call assert_equal(2, len(12))
index a8289633bf7c5903d4a982a9a3bba3bb465f8755..4dc9642a5c2b14934caa2a417feccfd278e72798 100644 (file)
@@ -738,6 +738,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    334,
 /**/
     333,
 /**/