diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-04-09 19:34:43 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-04-09 19:34:43 +0200 |
commit | 5da356e07359a59cf2d682908ba8592a72d5d9cd (patch) | |
tree | 7769114608235782984c94061cef30c974537ba4 /src/vim9compile.c | |
parent | 4d23c52824dd2f4577eb980e7d91feed34052755 (diff) |
patch 8.2.0536: Vim9: some compilation code not testedv8.2.0536
Problem: Vim9: some compilation code not tested.
Solution: Add more test cases.
Diffstat (limited to 'src/vim9compile.c')
-rw-r--r-- | src/vim9compile.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/vim9compile.c b/src/vim9compile.c index a8a7647468..0bc50c3e02 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -403,7 +403,7 @@ typval2type(typval_T *tv) return &t_list_string; if (tv->v_type == VAR_DICT) // e.g. for v:completed_item return &t_dict_any; - return &t_any; + return &t_any; // not used } ///////////////////////////////////////////////////////////////////// @@ -974,7 +974,7 @@ generate_LOAD( } /* - * Generate an ISN_LOADV instruction. + * Generate an ISN_LOADV instruction for v:var. */ static int generate_LOADV( @@ -982,8 +982,9 @@ generate_LOADV( char_u *name, int error) { - // load v:var - int vidx = find_vim_var(name); + int di_flags; + int vidx = find_vim_var(name, &di_flags); + type_T *type; RETURN_OK_IF_SKIP(cctx); if (vidx < 0) @@ -992,9 +993,9 @@ generate_LOADV( semsg(_(e_var_notfound), name); return FAIL; } + type = typval2type(get_vim_var_tv(vidx)); - // TODO: get actual type - return generate_LOAD(cctx, ISN_LOADV, vidx, NULL, &t_any); + return generate_LOAD(cctx, ISN_LOADV, vidx, NULL, type); } /* @@ -3907,14 +3908,18 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx) } else if (STRNCMP(arg, "v:", 2) == 0) { - typval_T *vtv; + typval_T *vtv; + int di_flags; - vimvaridx = find_vim_var(name + 2); + vimvaridx = find_vim_var(name + 2, &di_flags); if (vimvaridx < 0) { semsg(_(e_var_notfound), arg); goto theend; } + // We use the current value of "sandbox" here, is that OK? + if (var_check_ro(di_flags, name, FALSE)) + goto theend; dest = dest_vimvar; vtv = get_vim_var_tv(vimvaridx); type = typval2type(vtv); |