comparison src/channel.c @ 29994:86eb4aba16c3 v9.0.0335

patch 9.0.0335: checks for Dictionary argument often give a vague error Commit: https://github.com/vim/vim/commit/04c4c5746e15884768d2cb41370c3276a196cd4c Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Tue Aug 30 19:48:24 2022 +0100 patch 9.0.0335: checks for Dictionary argument often give a vague error Problem: Checks for Dictionary argument often give a vague error message. Solution: Give a useful error message. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/11009)
author Bram Moolenaar <Bram@vim.org>
date Tue, 30 Aug 2022 21:00:05 +0200
parents 89e1d67814a9
children d269dd3cd31d
comparison
equal deleted inserted replaced
29993:8dd1900432a0 29994:86eb4aba16c3
1390 || check_for_opt_dict_arg(argvars, 1) == FAIL)) 1390 || check_for_opt_dict_arg(argvars, 1) == FAIL))
1391 return NULL; 1391 return NULL;
1392 1392
1393 address = tv_get_string(&argvars[0]); 1393 address = tv_get_string(&argvars[0]);
1394 if (argvars[1].v_type != VAR_UNKNOWN 1394 if (argvars[1].v_type != VAR_UNKNOWN
1395 && (argvars[1].v_type != VAR_DICT || argvars[1].vval.v_dict == NULL)) 1395 && check_for_nonnull_dict_arg(argvars, 1) == FAIL)
1396 {
1397 emsg(_(e_invalid_argument));
1398 return NULL; 1396 return NULL;
1399 }
1400 1397
1401 if (*address == NUL) 1398 if (*address == NUL)
1402 { 1399 {
1403 semsg(_(e_invalid_argument_str), address); 1400 semsg(_(e_invalid_argument_str), address);
1404 return NULL; 1401 return NULL;
4599 4596
4600 // return an empty dict by default 4597 // return an empty dict by default
4601 if (rettv_dict_alloc(rettv) == FAIL) 4598 if (rettv_dict_alloc(rettv) == FAIL)
4602 return; 4599 return;
4603 4600
4604 if (argvars[1].v_type != VAR_DICT) 4601 if (check_for_dict_arg(argvars, 1) == FAIL)
4605 {
4606 semsg(_(e_dict_required_for_argument_nr), 2);
4607 return; 4602 return;
4608 } 4603
4609 d = argvars[1].vval.v_dict; 4604 d = argvars[1].vval.v_dict;
4610 di = dict_find(d, (char_u *)"id", -1); 4605 di = dict_find(d, (char_u *)"id", -1);
4611 if (di != NULL && di->di_tv.v_type != VAR_NUMBER) 4606 if (di != NULL && di->di_tv.v_type != VAR_NUMBER)
4612 { 4607 {
4613 // only number type is supported for the 'id' item 4608 // only number type is supported for the 'id' item