comparison src/popupwin.c @ 25384:e8e2c4d33b9b v8.2.3229

patch 8.2.3229: Vim9: runtime and compile time type checks are not the same Commit: https://github.com/vim/vim/commit/4490ec4e839e45a2e6923c265c7e9e64c240b805 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Tue Jul 27 22:00:44 2021 +0200 patch 8.2.3229: Vim9: runtime and compile time type checks are not the same Problem: Vim9: runtime and compile time type checks are not the same. Solution: Add more runtime type checks for builtin functions. (Yegappan Lakshmanan, closes #8646)
author Bram Moolenaar <Bram@vim.org>
date Tue, 27 Jul 2021 22:15:06 +0200
parents 1ffa8eb30353
children 7cb1597067e0
comparison
equal deleted inserted replaced
25383:510e4fcb5363 25384:e8e2c4d33b9b
1849 buf_T *buf = NULL; 1849 buf_T *buf = NULL;
1850 dict_T *d = NULL; 1850 dict_T *d = NULL;
1851 int nr; 1851 int nr;
1852 int i; 1852 int i;
1853 1853
1854 if (in_vim9script()
1855 && (check_for_string_or_number_or_list_arg(argvars, 0) == FAIL
1856 || check_for_dict_arg(argvars, 1) == FAIL))
1857 return NULL;
1858
1854 if (argvars != NULL) 1859 if (argvars != NULL)
1855 { 1860 {
1856 // Check that arguments look OK. 1861 // Check that arguments look OK.
1857 if (argvars[0].v_type == VAR_NUMBER) 1862 if (argvars[0].v_type == VAR_NUMBER)
1858 { 1863 {
2139 void 2144 void
2140 f_popup_clear(typval_T *argvars, typval_T *rettv UNUSED) 2145 f_popup_clear(typval_T *argvars, typval_T *rettv UNUSED)
2141 { 2146 {
2142 int force = FALSE; 2147 int force = FALSE;
2143 2148
2149 if (in_vim9script() && check_for_opt_bool_arg(argvars, 0) == FAIL)
2150 return;
2151
2144 if (argvars[0].v_type != VAR_UNKNOWN) 2152 if (argvars[0].v_type != VAR_UNKNOWN)
2145 force = (int)tv_get_bool(&argvars[0]); 2153 force = (int)tv_get_bool(&argvars[0]);
2146 close_all_popups(force); 2154 close_all_popups(force);
2147 } 2155 }
2148 2156
2556 * popup_hide({id}) 2564 * popup_hide({id})
2557 */ 2565 */
2558 void 2566 void
2559 f_popup_hide(typval_T *argvars, typval_T *rettv UNUSED) 2567 f_popup_hide(typval_T *argvars, typval_T *rettv UNUSED)
2560 { 2568 {
2561 int id = (int)tv_get_number(argvars); 2569 int id;
2562 win_T *wp = find_popup_win(id); 2570 win_T *wp;
2563 2571
2572 if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL)
2573 return;
2574
2575 id = (int)tv_get_number(argvars);
2576 wp = find_popup_win(id);
2564 if (wp != NULL) 2577 if (wp != NULL)
2565 popup_hide(wp); 2578 popup_hide(wp);
2566 } 2579 }
2567 2580
2568 void 2581 void
2580 * popup_show({id}) 2593 * popup_show({id})
2581 */ 2594 */
2582 void 2595 void
2583 f_popup_show(typval_T *argvars, typval_T *rettv UNUSED) 2596 f_popup_show(typval_T *argvars, typval_T *rettv UNUSED)
2584 { 2597 {
2585 int id = (int)tv_get_number(argvars); 2598 int id;
2586 win_T *wp = find_popup_win(id); 2599 win_T *wp;
2587 2600
2601 if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL)
2602 return;
2603
2604 id = (int)tv_get_number(argvars);
2605 wp = find_popup_win(id);
2588 if (wp != NULL) 2606 if (wp != NULL)
2589 { 2607 {
2590 popup_show(wp); 2608 popup_show(wp);
2591 #ifdef FEAT_QUICKFIX 2609 #ifdef FEAT_QUICKFIX
2592 if (wp->w_popup_flags & POPF_INFO) 2610 if (wp->w_popup_flags & POPF_INFO)
2822 */ 2840 */
2823 void 2841 void
2824 f_popup_getpos(typval_T *argvars, typval_T *rettv) 2842 f_popup_getpos(typval_T *argvars, typval_T *rettv)
2825 { 2843 {
2826 dict_T *dict; 2844 dict_T *dict;
2827 int id = (int)tv_get_number(argvars); 2845 int id;
2828 win_T *wp = find_popup_win(id); 2846 win_T *wp;
2829 int top_extra; 2847 int top_extra;
2830 int left_extra; 2848 int left_extra;
2831 2849
2832 if (rettv_dict_alloc(rettv) == OK) 2850 if (rettv_dict_alloc(rettv) == OK)
2833 { 2851 {
2852 if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL)
2853 return;
2854
2855 id = (int)tv_get_number(argvars);
2856 wp = find_popup_win(id);
2834 if (wp == NULL) 2857 if (wp == NULL)
2835 return; // invalid {id} 2858 return; // invalid {id}
2836 top_extra = popup_top_extra(wp); 2859 top_extra = popup_top_extra(wp);
2837 left_extra = wp->w_popup_border[3] + wp->w_popup_padding[3]; 2860 left_extra = wp->w_popup_border[3] + wp->w_popup_padding[3];
2838 2861
2884 * popup_locate({row}, {col}) 2907 * popup_locate({row}, {col})
2885 */ 2908 */
2886 void 2909 void
2887 f_popup_locate(typval_T *argvars, typval_T *rettv) 2910 f_popup_locate(typval_T *argvars, typval_T *rettv)
2888 { 2911 {
2889 int row = tv_get_number(&argvars[0]) - 1; 2912 int row;
2890 int col = tv_get_number(&argvars[1]) - 1; 2913 int col;
2891 win_T *wp; 2914 win_T *wp;
2892 2915
2916 if (in_vim9script()
2917 && (check_for_number_arg(argvars, 0) == FAIL
2918 || check_for_number_arg(argvars, 1) == FAIL))
2919 return;
2920
2921 row = tv_get_number(&argvars[0]) - 1;
2922 col = tv_get_number(&argvars[1]) - 1;
2893 wp = mouse_find_win(&row, &col, FIND_POPUP); 2923 wp = mouse_find_win(&row, &col, FIND_POPUP);
2894 if (wp != NULL && WIN_IS_POPUP(wp)) 2924 if (wp != NULL && WIN_IS_POPUP(wp))
2895 rettv->vval.v_number = wp->w_id; 2925 rettv->vval.v_number = wp->w_id;
2896 } 2926 }
2897 2927
3001 */ 3031 */
3002 void 3032 void
3003 f_popup_getoptions(typval_T *argvars, typval_T *rettv) 3033 f_popup_getoptions(typval_T *argvars, typval_T *rettv)
3004 { 3034 {
3005 dict_T *dict; 3035 dict_T *dict;
3006 int id = (int)tv_get_number(argvars); 3036 int id;
3007 win_T *wp = find_popup_win(id); 3037 win_T *wp;
3008 tabpage_T *tp; 3038 tabpage_T *tp;
3009 int i; 3039 int i;
3010 3040
3011 if (rettv_dict_alloc(rettv) == OK) 3041 if (rettv_dict_alloc(rettv) == OK)
3012 { 3042 {
3043 if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL)
3044 return;
3045
3046 id = (int)tv_get_number(argvars);
3047 wp = find_popup_win(id);
3013 if (wp == NULL) 3048 if (wp == NULL)
3014 return; 3049 return;
3015 3050
3016 dict = rettv->vval.v_dict; 3051 dict = rettv->vval.v_dict;
3017 dict_add_number(dict, "line", wp->w_wantline); 3052 dict_add_number(dict, "line", wp->w_wantline);