comparison src/popupwin.c @ 25252:acda780ffc3e v8.2.3162

patch 8.2.3162: Vim9: argument types are not checked at compile time Commit: https://github.com/vim/vim/commit/1a71d31bf34b0b2b08517903826004ec6fd440e5 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Thu Jul 15 12:49:58 2021 +0200 patch 8.2.3162: Vim9: argument types are not checked at compile time Problem: Vim9: argument types are not checked at compile time. Solution: Add more type checks. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/8560)
author Bram Moolenaar <Bram@vim.org>
date Thu, 15 Jul 2021 13:00:06 +0200
parents 8f2262c72178
children e56c8dc1a534
comparison
equal deleted inserted replaced
25251:6024f64e0d2b 25252:acda780ffc3e
2357 * popup_filter_menu({id}, {key}) 2357 * popup_filter_menu({id}, {key})
2358 */ 2358 */
2359 void 2359 void
2360 f_popup_filter_menu(typval_T *argvars, typval_T *rettv) 2360 f_popup_filter_menu(typval_T *argvars, typval_T *rettv)
2361 { 2361 {
2362 int id = tv_get_number(&argvars[0]); 2362 int id;
2363 win_T *wp = win_id2wp(id); 2363 win_T *wp;
2364 char_u *key = tv_get_string(&argvars[1]); 2364 char_u *key;
2365 typval_T res; 2365 typval_T res;
2366 int c; 2366 int c;
2367 linenr_T old_lnum; 2367 linenr_T old_lnum;
2368 2368
2369 if (in_vim9script()
2370 && (check_for_number_arg(argvars, 0) == FAIL
2371 || check_for_string_arg(argvars, 1) == FAIL))
2372 return;
2373
2374 id = tv_get_number(&argvars[0]);
2375 wp = win_id2wp(id);
2376 key = tv_get_string(&argvars[1]);
2369 // If the popup has been closed do not consume the key. 2377 // If the popup has been closed do not consume the key.
2370 if (wp == NULL) 2378 if (wp == NULL)
2371 return; 2379 return;
2372 2380
2373 c = *key; 2381 c = *key;
2414 * popup_filter_yesno({id}, {key}) 2422 * popup_filter_yesno({id}, {key})
2415 */ 2423 */
2416 void 2424 void
2417 f_popup_filter_yesno(typval_T *argvars, typval_T *rettv) 2425 f_popup_filter_yesno(typval_T *argvars, typval_T *rettv)
2418 { 2426 {
2419 int id = tv_get_number(&argvars[0]); 2427 int id;
2420 win_T *wp = win_id2wp(id); 2428 win_T *wp;
2421 char_u *key = tv_get_string(&argvars[1]); 2429 char_u *key;
2422 typval_T res; 2430 typval_T res;
2423 int c; 2431 int c;
2424 2432
2433 if (in_vim9script()
2434 && (check_for_number_arg(argvars, 0) == FAIL
2435 || check_for_string_arg(argvars, 1) == FAIL))
2436 return;
2437
2438 id = tv_get_number(&argvars[0]);
2439 wp = win_id2wp(id);
2440 key = tv_get_string(&argvars[1]);
2425 // If the popup has been closed don't consume the key. 2441 // If the popup has been closed don't consume the key.
2426 if (wp == NULL) 2442 if (wp == NULL)
2427 return; 2443 return;
2428 2444
2429 c = *key; 2445 c = *key;
2725 */ 2741 */
2726 void 2742 void
2727 f_popup_move(typval_T *argvars, typval_T *rettv UNUSED) 2743 f_popup_move(typval_T *argvars, typval_T *rettv UNUSED)
2728 { 2744 {
2729 dict_T *dict; 2745 dict_T *dict;
2730 int id = (int)tv_get_number(argvars); 2746 int id;
2731 win_T *wp = find_popup_win(id); 2747 win_T *wp;
2732 2748
2749 if (in_vim9script()
2750 && (check_for_number_arg(argvars, 0) == FAIL
2751 || check_for_dict_arg(argvars, 1) == FAIL))
2752 return;
2753
2754 id = (int)tv_get_number(argvars);
2755 wp = find_popup_win(id);
2733 if (wp == NULL) 2756 if (wp == NULL)
2734 return; // invalid {id} 2757 return; // invalid {id}
2735 2758
2736 if (argvars[1].v_type != VAR_DICT || argvars[1].vval.v_dict == NULL) 2759 if (argvars[1].v_type != VAR_DICT || argvars[1].vval.v_dict == NULL)
2737 { 2760 {
2752 */ 2775 */
2753 void 2776 void
2754 f_popup_setoptions(typval_T *argvars, typval_T *rettv UNUSED) 2777 f_popup_setoptions(typval_T *argvars, typval_T *rettv UNUSED)
2755 { 2778 {
2756 dict_T *dict; 2779 dict_T *dict;
2757 int id = (int)tv_get_number(argvars); 2780 int id;
2758 win_T *wp = find_popup_win(id); 2781 win_T *wp;
2759 linenr_T old_firstline; 2782 linenr_T old_firstline;
2760 2783
2784 if (in_vim9script()
2785 && (check_for_number_arg(argvars, 0) == FAIL
2786 || check_for_dict_arg(argvars, 1) == FAIL))
2787 return;
2788
2789 id = (int)tv_get_number(argvars);
2790 wp = find_popup_win(id);
2761 if (wp == NULL) 2791 if (wp == NULL)
2762 return; // invalid {id} 2792 return; // invalid {id}
2763 2793
2764 if (argvars[1].v_type != VAR_DICT || argvars[1].vval.v_dict == NULL) 2794 if (argvars[1].v_type != VAR_DICT || argvars[1].vval.v_dict == NULL)
2765 { 2795 {