diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-04-19 18:27:26 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-04-19 18:27:26 +0200 |
commit | 7bdaea6e0df849cf3dd7eaaf454eb88f637d1884 (patch) | |
tree | fb91b5cbe233e4fe9ab0b52a7851a6f47c5cd84c /src/vim9compile.c | |
parent | eb58a2465825c258beafae96240824923f73779f (diff) |
patch 8.2.0605: Vim9: cannot unlet an environment variablev8.2.0605
Problem: Vim9: cannot unlet an environment variable.
Solution: Implement unlet for $VAR.
Diffstat (limited to 'src/vim9compile.c')
-rw-r--r-- | src/vim9compile.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/vim9compile.c b/src/vim9compile.c index c4a5c08d89..daa1cbea41 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -990,12 +990,12 @@ generate_LOADV( * Generate an ISN_UNLET instruction. */ static int -generate_UNLET(cctx_T *cctx, char_u *name, int forceit) +generate_UNLET(cctx_T *cctx, isntype_T isn_type, char_u *name, int forceit) { isn_T *isn; RETURN_OK_IF_SKIP(cctx); - if ((isn = generate_instr(cctx, ISN_UNLET)) == NULL) + if ((isn = generate_instr(cctx, isn_type)) == NULL) return FAIL; isn->isn_arg.unlet.ul_name = vim_strsave(name); isn->isn_arg.unlet.ul_forceit = forceit; @@ -4594,10 +4594,12 @@ compile_unlet( // Normal name. Only supports g:, w:, t: and b: namespaces. *name_end = NUL; - if (check_vim9_unlet(p) == FAIL) + if (*p == '$') + ret = generate_UNLET(cctx, ISN_UNLETENV, p + 1, eap->forceit); + else if (check_vim9_unlet(p) == FAIL) ret = FAIL; else - ret = generate_UNLET(cctx, p, eap->forceit); + ret = generate_UNLET(cctx, ISN_UNLET, p, eap->forceit); *name_end = cc; return ret; @@ -6363,6 +6365,7 @@ delete_instr(isn_T *isn) break; case ISN_UNLET: + case ISN_UNLETENV: vim_free(isn->isn_arg.unlet.ul_name); break; |