comparison src/vim9compile.c @ 26356:0884f2be6c2a v8.2.3709

patch 8.2.3709: Vim9: backtick expression expanded when not desired Commit: https://github.com/vim/vim/commit/fad2742d538123abb9b384a053fd581f2acf6bb0 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Nov 30 21:58:19 2021 +0000 patch 8.2.3709: Vim9: backtick expression expanded when not desired Problem: Vim9: backtick expression expanded when not desired. Solution: Only expand a backtick expression for commands that expand their argument. Remove a few outdated TODO comments.
author Bram Moolenaar <Bram@vim.org>
date Tue, 30 Nov 2021 23:00:04 +0100
parents f209f28ad898
children 80b555c4aed0
comparison
equal deleted inserted replaced
26355:106547a11f1c 26356:0884f2be6c2a
7896 else if (instr->ga_len == instr_count && ppconst.pp_used == 1) 7896 else if (instr->ga_len == instr_count && ppconst.pp_used == 1)
7897 { 7897 {
7898 int error = FALSE; 7898 int error = FALSE;
7899 int v; 7899 int v;
7900 7900
7901 // The expression results in a constant. 7901 // The expression result is a constant.
7902 // TODO: how about nesting?
7903 v = tv_get_bool_chk(&ppconst.pp_tv[0], &error); 7902 v = tv_get_bool_chk(&ppconst.pp_tv[0], &error);
7904 if (error) 7903 if (error)
7905 return NULL; 7904 return NULL;
7906 cctx->ctx_skip = v ? SKIP_NOT : SKIP_YES; 7905 cctx->ctx_skip = v ? SKIP_NOT : SKIP_YES;
7907 clear_ppconst(&ppconst); 7906 clear_ppconst(&ppconst);
8169 { 8168 {
8170 if (!var_list) 8169 if (!var_list)
8171 item_type = vartype->tt_member; 8170 item_type = vartype->tt_member;
8172 else if (vartype->tt_member->tt_type == VAR_LIST 8171 else if (vartype->tt_member->tt_type == VAR_LIST
8173 && vartype->tt_member->tt_member->tt_type != VAR_ANY) 8172 && vartype->tt_member->tt_member->tt_type != VAR_ANY)
8174 // TODO: should get the type for each lhs
8175 item_type = vartype->tt_member->tt_member; 8173 item_type = vartype->tt_member->tt_member;
8176 } 8174 }
8177 8175
8178 // CMDMOD_REV must come before the FOR instruction. 8176 // CMDMOD_REV must come before the FOR instruction.
8179 generate_undo_cmdmods(cctx); 8177 generate_undo_cmdmods(cctx);
8222 { 8220 {
8223 p = skipwhite(p + 1); 8221 p = skipwhite(p + 1);
8224 lhs_type = parse_type(&p, cctx->ctx_type_list, TRUE); 8222 lhs_type = parse_type(&p, cctx->ctx_type_list, TRUE);
8225 } 8223 }
8226 8224
8227 // TODO: script var not supported? 8225 // Script var is not supported.
8228 if (get_var_dest(name, &dest, CMD_for, &opt_flags, 8226 if (get_var_dest(name, &dest, CMD_for, &opt_flags,
8229 &vimvaridx, &type, cctx) == FAIL) 8227 &vimvaridx, &type, cctx) == FAIL)
8230 goto failed; 8228 goto failed;
8231 if (dest != dest_local) 8229 if (dest != dest_local)
8232 { 8230 {
8769 8767
8770 this_instr = instr->ga_len; 8768 this_instr = instr->ga_len;
8771 #ifdef FEAT_PROFILE 8769 #ifdef FEAT_PROFILE
8772 if (cctx->ctx_compile_type == CT_PROFILE 8770 if (cctx->ctx_compile_type == CT_PROFILE
8773 && ((isn_T *)instr->ga_data)[this_instr - 1] 8771 && ((isn_T *)instr->ga_data)[this_instr - 1]
8774 .isn_type == ISN_PROF_START) 8772 .isn_type == ISN_PROF_START)
8775 { 8773 {
8776 // jump to the profile start of the "finally" 8774 // jump to the profile start of the "finally"
8777 --this_instr; 8775 --this_instr;
8778 8776
8779 // jump to the profile end above it 8777 // jump to the profile end above it
8780 if (this_instr > 0 && ((isn_T *)instr->ga_data)[this_instr - 1] 8778 if (this_instr > 0 && ((isn_T *)instr->ga_data)[this_instr - 1]
8781 .isn_type == ISN_PROF_END) 8779 .isn_type == ISN_PROF_END)
8782 --this_instr; 8780 --this_instr;
8783 } 8781 }
8784 #endif 8782 #endif
8785 8783
8786 // Fill in the "end" label in jumps at the end of the blocks. 8784 // Fill in the "end" label in jumps at the end of the blocks.
8787 compile_fill_jump_to_end(&scope->se_u.se_try.ts_end_label, 8785 compile_fill_jump_to_end(&scope->se_u.se_try.ts_end_label,
8788 this_instr, cctx); 8786 this_instr, cctx);
8789 8787
8790 // If there is no :catch then an exception jumps to :finally. 8788 // If there is no :catch then an exception jumps to :finally.
8791 if (isn->isn_arg.try.try_ref->try_catch == 0) 8789 if (isn->isn_arg.try.try_ref->try_catch == 0)
8792 isn->isn_arg.try.try_ref->try_catch = this_instr; 8790 isn->isn_arg.try.try_ref->try_catch = this_instr;
8793 isn->isn_arg.try.try_ref->try_finally = this_instr; 8791 isn->isn_arg.try.try_ref->try_finally = this_instr;
8798 isn->isn_arg.jump.jump_where = this_instr; 8796 isn->isn_arg.jump.jump_where = this_instr;
8799 scope->se_u.se_try.ts_catch_label = 0; 8797 scope->se_u.se_try.ts_catch_label = 0;
8800 } 8798 }
8801 if (generate_instr(cctx, ISN_FINALLY) == NULL) 8799 if (generate_instr(cctx, ISN_FINALLY) == NULL)
8802 return NULL; 8800 return NULL;
8803
8804 // TODO: set index in ts_finally_label jumps
8805 } 8801 }
8806 8802
8807 return arg; 8803 return arg;
8808 } 8804 }
8809 8805
9182 } 9178 }
9183 } 9179 }
9184 9180
9185 if (eap->cmdidx == CMD_folddoopen || eap->cmdidx == CMD_folddoclosed) 9181 if (eap->cmdidx == CMD_folddoopen || eap->cmdidx == CMD_folddoclosed)
9186 { 9182 {
9187 // TODO: should only expand when appropriate for the command 9183 exarg_T nea;
9188 eap->arg = skiptowhite(eap->arg); 9184
9189 has_expr = TRUE; 9185 CLEAR_FIELD(nea);
9186 nea.cmd = eap->arg;
9187 p = find_ex_command(&nea, NULL, lookup_scriptitem, NULL);
9188 if (nea.cmdidx <= CMD_SIZE)
9189 {
9190 has_expr = excmd_get_argt(nea.cmdidx) & (EX_XFILE | EX_EXPAND);
9191 if (has_expr)
9192 eap->arg = skiptowhite(eap->arg);
9193 }
9190 } 9194 }
9191 9195
9192 if (has_expr && (p = (char_u *)strstr((char *)eap->arg, "`=")) != NULL) 9196 if (has_expr && (p = (char_u *)strstr((char *)eap->arg, "`=")) != NULL)
9193 { 9197 {
9194 int count = 0; 9198 int count = 0;