patch 8.2.3229: Vim9: runtime and compile time type checks are not the same

Problem:    Vim9: runtime and compile time type checks are not the same.
Solution:   Add more runtime type checks for builtin functions. (Yegappan
            Lakshmanan, closes #8646)
diff --git a/src/float.c b/src/float.c
index 7c02044..898095f 100644
--- a/src/float.c
+++ b/src/float.c
@@ -82,6 +82,9 @@
     void
 f_abs(typval_T *argvars, typval_T *rettv)
 {
+    if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
+	return;
+
     if (argvars[0].v_type == VAR_FLOAT)
     {
 	rettv->v_type = VAR_FLOAT;
@@ -110,6 +113,9 @@
 {
     float_T	f = 0.0;
 
+    if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
+	return;
+
     rettv->v_type = VAR_FLOAT;
     if (get_float_arg(argvars, &f) == OK)
 	rettv->vval.v_float = acos(f);
@@ -125,6 +131,9 @@
 {
     float_T	f = 0.0;
 
+    if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
+	return;
+
     rettv->v_type = VAR_FLOAT;
     if (get_float_arg(argvars, &f) == OK)
 	rettv->vval.v_float = asin(f);
@@ -140,6 +149,9 @@
 {
     float_T	f = 0.0;
 
+    if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
+	return;
+
     rettv->v_type = VAR_FLOAT;
     if (get_float_arg(argvars, &f) == OK)
 	rettv->vval.v_float = atan(f);
@@ -155,6 +167,11 @@
 {
     float_T	fx = 0.0, fy = 0.0;
 
+    if (in_vim9script()
+	    && (check_for_float_or_nr_arg(argvars, 0) == FAIL
+		|| check_for_float_or_nr_arg(argvars, 1) == FAIL))
+	return;
+
     rettv->v_type = VAR_FLOAT;
     if (get_float_arg(argvars, &fx) == OK
 				     && get_float_arg(&argvars[1], &fy) == OK)
@@ -171,6 +188,9 @@
 {
     float_T	f = 0.0;
 
+    if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
+	return;
+
     rettv->v_type = VAR_FLOAT;
     if (get_float_arg(argvars, &f) == OK)
 	rettv->vval.v_float = ceil(f);
@@ -186,6 +206,9 @@
 {
     float_T	f = 0.0;
 
+    if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
+	return;
+
     rettv->v_type = VAR_FLOAT;
     if (get_float_arg(argvars, &f) == OK)
 	rettv->vval.v_float = cos(f);
@@ -201,6 +224,9 @@
 {
     float_T	f = 0.0;
 
+    if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
+	return;
+
     rettv->v_type = VAR_FLOAT;
     if (get_float_arg(argvars, &f) == OK)
 	rettv->vval.v_float = cosh(f);
@@ -216,6 +242,9 @@
 {
     float_T	f = 0.0;
 
+    if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
+	return;
+
     rettv->v_type = VAR_FLOAT;
     if (get_float_arg(argvars, &f) == OK)
 	rettv->vval.v_float = exp(f);
@@ -231,6 +260,9 @@
 {
     float_T	f = 0.0;
 
+    if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
+	return;
+
     if (get_float_arg(argvars, &f) == OK)
     {
 	if (f <= (float_T)-VARNUM_MAX + DBL_EPSILON)
@@ -250,6 +282,9 @@
 {
     float_T	f = 0.0;
 
+    if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
+	return;
+
     rettv->v_type = VAR_FLOAT;
     if (get_float_arg(argvars, &f) == OK)
 	rettv->vval.v_float = floor(f);
@@ -265,6 +300,11 @@
 {
     float_T	fx = 0.0, fy = 0.0;
 
+    if (in_vim9script()
+	    && (check_for_float_or_nr_arg(argvars, 0) == FAIL
+		|| check_for_float_or_nr_arg(argvars, 1) == FAIL))
+	return;
+
     rettv->v_type = VAR_FLOAT;
     if (get_float_arg(argvars, &fx) == OK
 				     && get_float_arg(&argvars[1], &fy) == OK)
@@ -280,6 +320,9 @@
     void
 f_isinf(typval_T *argvars, typval_T *rettv)
 {
+    if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
+	return;
+
     if (argvars[0].v_type == VAR_FLOAT && isinf(argvars[0].vval.v_float))
 	rettv->vval.v_number = argvars[0].vval.v_float > 0.0 ? 1 : -1;
 }
@@ -290,6 +333,9 @@
     void
 f_isnan(typval_T *argvars, typval_T *rettv)
 {
+    if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
+	return;
+
     rettv->vval.v_number = argvars[0].v_type == VAR_FLOAT
 					    && isnan(argvars[0].vval.v_float);
 }
@@ -303,6 +349,9 @@
 {
     float_T	f = 0.0;
 
+    if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
+	return;
+
     rettv->v_type = VAR_FLOAT;
     if (get_float_arg(argvars, &f) == OK)
 	rettv->vval.v_float = log(f);
@@ -318,6 +367,9 @@
 {
     float_T	f = 0.0;
 
+    if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
+	return;
+
     rettv->v_type = VAR_FLOAT;
     if (get_float_arg(argvars, &f) == OK)
 	rettv->vval.v_float = log10(f);
@@ -333,6 +385,11 @@
 {
     float_T	fx = 0.0, fy = 0.0;
 
+    if (in_vim9script()
+	    && (check_for_float_or_nr_arg(argvars, 0) == FAIL
+		|| check_for_float_or_nr_arg(argvars, 1) == FAIL))
+	return;
+
     rettv->v_type = VAR_FLOAT;
     if (get_float_arg(argvars, &fx) == OK
 				     && get_float_arg(&argvars[1], &fy) == OK)
@@ -359,6 +416,9 @@
 {
     float_T	f = 0.0;
 
+    if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
+	return;
+
     rettv->v_type = VAR_FLOAT;
     if (get_float_arg(argvars, &f) == OK)
 	rettv->vval.v_float = vim_round(f);
@@ -374,6 +434,9 @@
 {
     float_T	f = 0.0;
 
+    if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
+	return;
+
     rettv->v_type = VAR_FLOAT;
     if (get_float_arg(argvars, &f) == OK)
 	rettv->vval.v_float = sin(f);
@@ -389,6 +452,9 @@
 {
     float_T	f = 0.0;
 
+    if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
+	return;
+
     rettv->v_type = VAR_FLOAT;
     if (get_float_arg(argvars, &f) == OK)
 	rettv->vval.v_float = sinh(f);
@@ -404,6 +470,9 @@
 {
     float_T	f = 0.0;
 
+    if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
+	return;
+
     rettv->v_type = VAR_FLOAT;
     if (get_float_arg(argvars, &f) == OK)
 	rettv->vval.v_float = sqrt(f);
@@ -417,8 +486,14 @@
     void
 f_str2float(typval_T *argvars, typval_T *rettv)
 {
-    char_u *p = skipwhite(tv_get_string_strict(&argvars[0]));
-    int     isneg = (*p == '-');
+    char_u *p;
+    int     isneg;
+
+    if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
+	return;
+
+    p = skipwhite(tv_get_string_strict(&argvars[0]));
+    isneg = (*p == '-');
 
     if (*p == '+' || *p == '-')
 	p = skipwhite(p + 1);
@@ -436,6 +511,9 @@
 {
     float_T	f = 0.0;
 
+    if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
+	return;
+
     rettv->v_type = VAR_FLOAT;
     if (get_float_arg(argvars, &f) == OK)
 	rettv->vval.v_float = tan(f);
@@ -451,6 +529,9 @@
 {
     float_T	f = 0.0;
 
+    if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
+	return;
+
     rettv->v_type = VAR_FLOAT;
     if (get_float_arg(argvars, &f) == OK)
 	rettv->vval.v_float = tanh(f);
@@ -466,6 +547,9 @@
 {
     float_T	f = 0.0;
 
+    if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
+	return;
+
     rettv->v_type = VAR_FLOAT;
     if (get_float_arg(argvars, &f) == OK)
 	// trunc() is not in C90, use floor() or ceil() instead.