comparison src/vim9compile.c @ 19818:c1c88b333481 v8.2.0465

patch 8.2.0465: Vim9: dead code and wrong return type Commit: https://github.com/vim/vim/commit/599c89c82fe3c85378e8077b4e589f0ee4218da2 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 28 14:53:20 2020 +0100 patch 8.2.0465: Vim9: dead code and wrong return type Problem: Vim9: dead code and wrong return type. Solution: Remove dead code. Fix return type. Add more tests.
author Bram Moolenaar <Bram@vim.org>
date Sat, 28 Mar 2020 15:00:10 +0100
parents 99248f0ff29d
children fc3cdc819d80
comparison
equal deleted inserted replaced
19817:a6a2d6bfc30f 19818:c1c88b333481
240 if (member_type->tt_type == VAR_STRING) 240 if (member_type->tt_type == VAR_STRING)
241 return &t_list_string; 241 return &t_list_string;
242 242
243 // Not a common type, create a new entry. 243 // Not a common type, create a new entry.
244 if (ga_grow(type_list, 1) == FAIL) 244 if (ga_grow(type_list, 1) == FAIL)
245 return FAIL; 245 return &t_any;
246 type = ((type_T *)type_list->ga_data) + type_list->ga_len; 246 type = ((type_T *)type_list->ga_data) + type_list->ga_len;
247 ++type_list->ga_len; 247 ++type_list->ga_len;
248 type->tt_type = VAR_LIST; 248 type->tt_type = VAR_LIST;
249 type->tt_member = member_type; 249 type->tt_member = member_type;
250 return type; 250 return type;
267 if (member_type->tt_type == VAR_STRING) 267 if (member_type->tt_type == VAR_STRING)
268 return &t_dict_string; 268 return &t_dict_string;
269 269
270 // Not a common type, create a new entry. 270 // Not a common type, create a new entry.
271 if (ga_grow(type_list, 1) == FAIL) 271 if (ga_grow(type_list, 1) == FAIL)
272 return FAIL; 272 return &t_any;
273 type = ((type_T *)type_list->ga_data) + type_list->ga_len; 273 type = ((type_T *)type_list->ga_data) + type_list->ga_len;
274 ++type_list->ga_len; 274 ++type_list->ga_len;
275 type->tt_type = VAR_DICT; 275 type->tt_type = VAR_DICT;
276 type->tt_member = member_type; 276 type->tt_member = member_type;
277 return type; 277 return type;
1366 */ 1366 */
1367 static type_T * 1367 static type_T *
1368 parse_type_member(char_u **arg, type_T *type, garray_T *type_list) 1368 parse_type_member(char_u **arg, type_T *type, garray_T *type_list)
1369 { 1369 {
1370 type_T *member_type; 1370 type_T *member_type;
1371 int prev_called_emsg = called_emsg;
1371 1372
1372 if (**arg != '<') 1373 if (**arg != '<')
1373 { 1374 {
1374 if (*skipwhite(*arg) == '<') 1375 if (*skipwhite(*arg) == '<')
1375 emsg(_("E1007: No white space allowed before <")); 1376 emsg(_("E1007: No white space allowed before <"));
1378 return type; 1379 return type;
1379 } 1380 }
1380 *arg = skipwhite(*arg + 1); 1381 *arg = skipwhite(*arg + 1);
1381 1382
1382 member_type = parse_type(arg, type_list); 1383 member_type = parse_type(arg, type_list);
1383 if (member_type == NULL)
1384 return type;
1385 1384
1386 *arg = skipwhite(*arg); 1385 *arg = skipwhite(*arg);
1387 if (**arg != '>') 1386 if (**arg != '>' && called_emsg == prev_called_emsg)
1388 { 1387 {
1389 emsg(_("E1009: Missing > after type")); 1388 emsg(_("E1009: Missing > after type"));
1390 return type; 1389 return type;
1391 } 1390 }
1392 ++*arg; 1391 ++*arg;
1764 { 1763 {
1765 semsg(_("E1060: expected dot after name: %s"), start); 1764 semsg(_("E1060: expected dot after name: %s"), start);
1766 return FAIL; 1765 return FAIL;
1767 } 1766 }
1768 ++p; 1767 ++p;
1768 if (VIM_ISWHITE(*p))
1769 {
1770 emsg(_("E1074: no white space allowed after dot"));
1771 return FAIL;
1772 }
1769 1773
1770 idx = find_exported(import->imp_sid, &p, &name_len, &ufunc, &type); 1774 idx = find_exported(import->imp_sid, &p, &name_len, &ufunc, &type);
1771 // TODO: what if it is a function? 1775 // TODO: what if it is a function?
1772 if (idx < 0) 1776 if (idx < 0)
1773 return FAIL; 1777 return FAIL;
1804 { 1808 {
1805 type_T *type; 1809 type_T *type;
1806 char_u *name; 1810 char_u *name;
1807 char_u *end = end_arg; 1811 char_u *end = end_arg;
1808 int res = FAIL; 1812 int res = FAIL;
1813 int prev_called_emsg = called_emsg;
1809 1814
1810 if (*(*arg + 1) == ':') 1815 if (*(*arg + 1) == ':')
1811 { 1816 {
1812 // load namespaced variable 1817 // load namespaced variable
1813 name = vim_strnsave(*arg + 2, end - (*arg + 2)); 1818 name = vim_strnsave(*arg + 2, end - (*arg + 2));
1890 } 1895 }
1891 1896
1892 *arg = end; 1897 *arg = end;
1893 1898
1894 theend: 1899 theend:
1895 if (res == FAIL && error) 1900 if (res == FAIL && error && called_emsg == prev_called_emsg)
1896 semsg(_(e_var_notfound), name); 1901 semsg(_(e_var_notfound), name);
1897 vim_free(name); 1902 vim_free(name);
1898 return res; 1903 return res;
1899 } 1904 }
1900 1905