comparison src/eval.c @ 21644:7d3ba70a03f1 v8.2.1372

patch 8.2.1372: Vim9: no error for missing white space around operator Commit: https://github.com/vim/vim/commit/fdac71c5075062f97f77044e9619fa5c907e0327 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Aug 5 12:44:41 2020 +0200 patch 8.2.1372: Vim9: no error for missing white space around operator Problem: Vim9: no error for missing white space around operator. Solution: Check for white space around ? and :.
author Bram Moolenaar <Bram@vim.org>
date Wed, 05 Aug 2020 12:45:04 +0200
parents 5ae89c8633ae
children c3f6006bf0ba
comparison
equal deleted inserted replaced
21643:08894a73765b 21644:7d3ba70a03f1
2070 /* 2070 /*
2071 * Handle top level expression: 2071 * Handle top level expression:
2072 * expr2 ? expr1 : expr1 2072 * expr2 ? expr1 : expr1
2073 * 2073 *
2074 * "arg" must point to the first non-white of the expression. 2074 * "arg" must point to the first non-white of the expression.
2075 * "arg" is advanced to the next non-white after the recognized expression. 2075 * "arg" is advanced to just after the recognized expression.
2076 * 2076 *
2077 * Note: "rettv.v_lock" is not set. 2077 * Note: "rettv.v_lock" is not set.
2078 * 2078 *
2079 * Return OK or FAIL. 2079 * Return OK or FAIL.
2080 */ 2080 */
2109 evaluate = evalarg_used->eval_flags & EVAL_EVALUATE; 2109 evaluate = evalarg_used->eval_flags & EVAL_EVALUATE;
2110 2110
2111 if (getnext) 2111 if (getnext)
2112 *arg = eval_next_line(evalarg_used); 2112 *arg = eval_next_line(evalarg_used);
2113 else 2113 else
2114 {
2115 if (evaluate && in_vim9script() && !VIM_ISWHITE(p[-1]))
2116 {
2117 error_white_both(p, 1);
2118 clear_tv(rettv);
2119 return FAIL;
2120 }
2114 *arg = p; 2121 *arg = p;
2122 }
2115 2123
2116 result = FALSE; 2124 result = FALSE;
2117 if (evaluate) 2125 if (evaluate)
2118 { 2126 {
2119 int error = FALSE; 2127 int error = FALSE;
2126 } 2134 }
2127 2135
2128 /* 2136 /*
2129 * Get the second variable. Recursive! 2137 * Get the second variable. Recursive!
2130 */ 2138 */
2139 if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[1]))
2140 {
2141 error_white_both(p, 1);
2142 clear_tv(rettv);
2143 return FAIL;
2144 }
2131 *arg = skipwhite_and_linebreak(*arg + 1, evalarg_used); 2145 *arg = skipwhite_and_linebreak(*arg + 1, evalarg_used);
2132 evalarg_used->eval_flags = result ? orig_flags 2146 evalarg_used->eval_flags = result ? orig_flags
2133 : orig_flags & ~EVAL_EVALUATE; 2147 : orig_flags & ~EVAL_EVALUATE;
2134 if (eval1(arg, rettv, evalarg_used) == FAIL) 2148 if (eval1(arg, rettv, evalarg_used) == FAIL)
2135 return FAIL; 2149 return FAIL;
2146 return FAIL; 2160 return FAIL;
2147 } 2161 }
2148 if (getnext) 2162 if (getnext)
2149 *arg = eval_next_line(evalarg_used); 2163 *arg = eval_next_line(evalarg_used);
2150 else 2164 else
2165 {
2166 if (evaluate && in_vim9script() && !VIM_ISWHITE(p[-1]))
2167 {
2168 error_white_both(p, 1);
2169 clear_tv(rettv);
2170 return FAIL;
2171 }
2151 *arg = p; 2172 *arg = p;
2173 }
2152 2174
2153 /* 2175 /*
2154 * Get the third variable. Recursive! 2176 * Get the third variable. Recursive!
2155 */ 2177 */
2178 if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[1]))
2179 {
2180 error_white_both(p, 1);
2181 clear_tv(rettv);
2182 return FAIL;
2183 }
2156 *arg = skipwhite_and_linebreak(*arg + 1, evalarg_used); 2184 *arg = skipwhite_and_linebreak(*arg + 1, evalarg_used);
2157 evalarg_used->eval_flags = !result ? orig_flags 2185 evalarg_used->eval_flags = !result ? orig_flags
2158 : orig_flags & ~EVAL_EVALUATE; 2186 : orig_flags & ~EVAL_EVALUATE;
2159 if (eval1(arg, &var2, evalarg_used) == FAIL) 2187 if (eval1(arg, &var2, evalarg_used) == FAIL)
2160 { 2188 {
2177 /* 2205 /*
2178 * Handle first level expression: 2206 * Handle first level expression:
2179 * expr2 || expr2 || expr2 logical OR 2207 * expr2 || expr2 || expr2 logical OR
2180 * 2208 *
2181 * "arg" must point to the first non-white of the expression. 2209 * "arg" must point to the first non-white of the expression.
2182 * "arg" is advanced to the next non-white after the recognized expression. 2210 * "arg" is advanced to just after the recognized expression.
2183 * 2211 *
2184 * Return OK or FAIL. 2212 * Return OK or FAIL.
2185 */ 2213 */
2186 static int 2214 static int
2187 eval2(char_u **arg, typval_T *rettv, evalarg_T *evalarg) 2215 eval2(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
2308 /* 2336 /*
2309 * Handle second level expression: 2337 * Handle second level expression:
2310 * expr3 && expr3 && expr3 logical AND 2338 * expr3 && expr3 && expr3 logical AND
2311 * 2339 *
2312 * "arg" must point to the first non-white of the expression. 2340 * "arg" must point to the first non-white of the expression.
2313 * "arg" is advanced to the next non-white after the recognized expression. 2341 * "arg" is advanced to just after the recognized expression.
2314 * 2342 *
2315 * Return OK or FAIL. 2343 * Return OK or FAIL.
2316 */ 2344 */
2317 static int 2345 static int
2318 eval3(char_u **arg, typval_T *rettv, evalarg_T *evalarg) 2346 eval3(char_u **arg, typval_T *rettv, evalarg_T *evalarg)