Mercurial > vim
comparison src/job.c @ 25302:4d3c68196d05 v8.2.3188
patch 8.2.3188: Vim9: argument types are not checked at compile time
Commit: https://github.com/vim/vim/commit/83494b4ac61898f687d6ef9dce4bad5802fb8e51
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Tue Jul 20 17:51:51 2021 +0200
patch 8.2.3188: Vim9: argument types are not checked at compile time
Problem: Vim9: argument types are not checked at compile time.
Solution: Add several more type checks, also at runtime. (Yegappan
Lakshmanan, closes #8587)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 20 Jul 2021 18:00:06 +0200 |
parents | 712e867f9721 |
children | 7e620652bd13 |
comparison
equal
deleted
inserted
replaced
25301:fe178301fc04 | 25302:4d3c68196d05 |
---|---|
1724 { | 1724 { |
1725 buf_T *buf; | 1725 buf_T *buf; |
1726 char_u *text; | 1726 char_u *text; |
1727 | 1727 |
1728 if (in_vim9script() | 1728 if (in_vim9script() |
1729 && ((argvars[0].v_type != VAR_STRING | 1729 && (check_for_string_or_number_arg(argvars, 0) == FAIL |
1730 && argvars[0].v_type != VAR_NUMBER | |
1731 && check_for_string_arg(argvars, 0) == FAIL) | |
1732 || check_for_string_arg(argvars, 1) == FAIL)) | 1730 || check_for_string_arg(argvars, 1) == FAIL)) |
1733 return; | 1731 return; |
1734 | 1732 |
1735 if (check_secure()) | 1733 if (check_secure()) |
1736 return; | 1734 return; |
1873 * "job_setoptions()" function | 1871 * "job_setoptions()" function |
1874 */ | 1872 */ |
1875 void | 1873 void |
1876 f_job_setoptions(typval_T *argvars, typval_T *rettv UNUSED) | 1874 f_job_setoptions(typval_T *argvars, typval_T *rettv UNUSED) |
1877 { | 1875 { |
1878 job_T *job = get_job_arg(&argvars[0]); | 1876 job_T *job; |
1879 jobopt_T opt; | 1877 jobopt_T opt; |
1880 | 1878 |
1879 if (in_vim9script() | |
1880 && (check_for_job_arg(argvars, 0) == FAIL | |
1881 || check_for_dict_arg(argvars, 1) == FAIL)) | |
1882 return; | |
1883 | |
1884 job = get_job_arg(&argvars[0]); | |
1881 if (job == NULL) | 1885 if (job == NULL) |
1882 return; | 1886 return; |
1883 clear_job_options(&opt); | 1887 clear_job_options(&opt); |
1884 if (get_job_options(&argvars[1], &opt, JO_STOPONEXIT + JO_EXIT_CB, 0) == OK) | 1888 if (get_job_options(&argvars[1], &opt, JO_STOPONEXIT + JO_EXIT_CB, 0) == OK) |
1885 job_set_options(job, &opt); | 1889 job_set_options(job, &opt); |
1926 * "job_stop()" function | 1930 * "job_stop()" function |
1927 */ | 1931 */ |
1928 void | 1932 void |
1929 f_job_stop(typval_T *argvars, typval_T *rettv) | 1933 f_job_stop(typval_T *argvars, typval_T *rettv) |
1930 { | 1934 { |
1931 job_T *job = get_job_arg(&argvars[0]); | 1935 job_T *job; |
1932 | 1936 |
1937 if (in_vim9script() | |
1938 && (check_for_job_arg(argvars, 0) == FAIL | |
1939 || check_for_opt_string_or_number_arg(argvars, 1) == FAIL)) | |
1940 return; | |
1941 | |
1942 job = get_job_arg(&argvars[0]); | |
1933 if (job != NULL) | 1943 if (job != NULL) |
1934 rettv->vval.v_number = job_stop(job, argvars, NULL); | 1944 rettv->vval.v_number = job_stop(job, argvars, NULL); |
1935 } | 1945 } |
1936 | 1946 |
1937 /* | 1947 /* |