diff src/typval.c @ 24820:b1093c1ac109 v8.2.2948

patch 8.2.2948: substitute() accepts a number but not a float expression Commit: https://github.com/vim/vim/commit/7a2217bedd223df4c8bbebe731bf0b5fe8532533 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jun 6 12:33:49 2021 +0200 patch 8.2.2948: substitute() accepts a number but not a float expression Problem: Substitute() accepts a number but not a float expression. Solution: Also accept a float. (closes https://github.com/vim/vim/issues/8331)
author Bram Moolenaar <Bram@vim.org>
date Sun, 06 Jun 2021 12:45:02 +0200
parents 8fdf839af1f4
children 345619f35112
line wrap: on
line diff
--- a/src/typval.c
+++ b/src/typval.c
@@ -462,8 +462,13 @@ tv_get_string_buf_chk_strict(typval_T *v
 	    break;
 	case VAR_FLOAT:
 #ifdef FEAT_FLOAT
-	    emsg(_(e_float_as_string));
-	    break;
+	    if (strict)
+	    {
+		emsg(_(e_float_as_string));
+		break;
+	    }
+	    vim_snprintf((char *)buf, NUMBUFLEN, "%g", varp->vval.v_float);
+	    return buf;
 #endif
 	case VAR_STRING:
 	    if (varp->vval.v_string != NULL)