diff src/vim9compile.c @ 23422:bb0c53f4ef8b v8.2.2254

patch 8.2.2254: Vim9: bool option type is number Commit: https://github.com/vim/vim/commit/dd1f426bd617ac6a775f2e7795ff0b159e3fa315 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Dec 31 17:41:01 2020 +0100 patch 8.2.2254: Vim9: bool option type is number Problem: Vim9: bool option type is number. Solution: Have get_option_value() return a different value for bool and number options. (closes #7583)
author Bram Moolenaar <Bram@vim.org>
date Thu, 31 Dec 2020 17:45:04 +0100
parents 681f042ae5ac
children 5807e3958e38
line wrap: on
line diff
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -5191,9 +5191,9 @@ get_var_dest(
 
     if (*name == '&')
     {
-	int	cc;
-	long	numval;
-	int	opt_type;
+	int		cc;
+	long		numval;
+	getoption_T	opt_type;
 
 	*dest = dest_option;
 	if (cmdidx == CMD_final || cmdidx == CMD_const)
@@ -5214,15 +5214,24 @@ get_var_dest(
 	opt_type = get_option_value(skip_option_env_lead(name),
 						    &numval, NULL, *opt_flags);
 	*p = cc;
-	if (opt_type == -3)
-	{
-	    semsg(_(e_unknown_option), name);
-	    return FAIL;
-	}
-	if (opt_type == -2 || opt_type == 0)
-	    *type = &t_string;
-	else
-	    *type = &t_number;	// both number and boolean option
+	switch (opt_type)
+	{
+	    case gov_unknown:
+		    semsg(_(e_unknown_option), name);
+		    return FAIL;
+	    case gov_string:
+	    case gov_hidden_string:
+		    *type = &t_string;
+		    break;
+	    case gov_bool:
+	    case gov_hidden_bool:
+		    *type = &t_bool;
+		    break;
+	    case gov_number:
+	    case gov_hidden_number:
+		    *type = &t_number;
+		    break;
+	}
     }
     else if (*name == '$')
     {