patch 8.2.1861: Vim9: no specific error when parsing lambda fails
Problem: Vim9: no specific error when parsing lambda fails. Solution: Also give syntax errors when not evaluating. (closes #7154)
This commit is contained in:
		| @ -859,14 +859,11 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal) | ||||
| 	if (!vim9script) | ||||
| 	    *arg = skipwhite(*arg); | ||||
| 	if (**arg != ':') | ||||
| 	{ | ||||
| 	    if (evaluate) | ||||
| 	{ | ||||
| 	    if (*skipwhite(*arg) == ':') | ||||
| 		semsg(_(e_no_white_space_allowed_before_str), ":"); | ||||
| 	    else | ||||
| 		semsg(_(e_missing_dict_colon), *arg); | ||||
| 	    } | ||||
| 	    clear_tv(&tvkey); | ||||
| 	    goto failret; | ||||
| 	} | ||||
| @ -899,7 +896,6 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal) | ||||
| 	    item = dict_find(d, key, -1); | ||||
| 	    if (item != NULL) | ||||
| 	    { | ||||
| 		if (evaluate) | ||||
| 		semsg(_(e_duplicate_key), key); | ||||
| 		clear_tv(&tvkey); | ||||
| 		clear_tv(&tv); | ||||
| @ -936,21 +932,17 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal) | ||||
| 	if (**arg == '}') | ||||
| 	    break; | ||||
| 	if (!had_comma) | ||||
| 	{ | ||||
| 	    if (evaluate) | ||||
| 	{ | ||||
| 	    if (**arg == ',') | ||||
| 		semsg(_(e_no_white_space_allowed_before_str), ","); | ||||
| 	    else | ||||
| 		semsg(_(e_missing_dict_comma), *arg); | ||||
| 	    } | ||||
| 	    goto failret; | ||||
| 	} | ||||
|     } | ||||
|  | ||||
|     if (**arg != '}') | ||||
|     { | ||||
| 	if (evaluate) | ||||
| 	semsg(_(e_missing_dict_end), *arg); | ||||
| failret: | ||||
| 	if (d != NULL) | ||||
|  | ||||
| @ -1805,6 +1805,13 @@ def Test_expr7_lambda() | ||||
|   CheckDefExecFailure(["var s = 'asdf'->{a -> a}('x', 'y')"], | ||||
|         'E1106: 2 arguments too many') | ||||
|   CheckDefFailure(["echo 'asdf'->{a -> a}(x)"], 'E1001:', 1) | ||||
|  | ||||
|   CheckDefSuccess(['var Fx = {a -> #{k1: 0,', ' k2: 1}}']) | ||||
|   CheckDefFailure(['var Fx = {a -> #{k1: 0', ' k2: 1}}'], 'E722:', 2) | ||||
|   CheckDefFailure(['var Fx = {a -> #{k1: 0,', ' k2 1}}'], 'E720:', 2) | ||||
|  | ||||
|   CheckDefSuccess(['var Fx = {a -> [0,', ' 1]}']) | ||||
|   CheckDefFailure(['var Fx = {a -> [0', ' 1]}'], 'E696:', 2) | ||||
| enddef | ||||
|  | ||||
| def Test_expr7_lambda_vim9script() | ||||
| @ -2371,7 +2378,7 @@ func Test_expr7_fails() | ||||
|   call CheckDefFailure(["'yes'->", "Echo()"], 'E488: Trailing characters: ->', 1) | ||||
|  | ||||
|   call CheckDefExecFailure(["[1, 2->len()"], 'E697:', 2) | ||||
|   call CheckDefExecFailure(["#{a: 1->len()"], 'E488:', 1) | ||||
|   call CheckDefExecFailure(["#{a: 1->len()"], 'E722:', 1) | ||||
|   call CheckDefExecFailure(["{'a': 1->len()"], 'E723:', 2) | ||||
| endfunc | ||||
|  | ||||
|  | ||||
| @ -750,6 +750,8 @@ static char *(features[]) = | ||||
|  | ||||
| static int included_patches[] = | ||||
| {   /* Add new patch number below this line */ | ||||
| /**/ | ||||
|     1861, | ||||
| /**/ | ||||
|     1860, | ||||
| /**/ | ||||
|  | ||||
		Reference in New Issue
	
	Block a user