Patch 8.2.3709
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.
Files:      src/vim9compile.c, src/testdir/test_vim9_cmd.vim


*** ../vim-8.2.3708/src/vim9compile.c   2021-11-30 20:57:34.561305257 +0000
--- src/vim9compile.c   2021-11-30 21:57:29.860497699 +0000
***************
*** 7898,7905 ****
        int error = FALSE;
        int v;
  
!       // The expression results in a constant.
!       // TODO: how about nesting?
        v = tv_get_bool_chk(&ppconst.pp_tv[0], &error);
        if (error)
            return NULL;
--- 7898,7904 ----
        int error = FALSE;
        int v;
  
!       // The expression result is a constant.
        v = tv_get_bool_chk(&ppconst.pp_tv[0], &error);
        if (error)
            return NULL;
***************
*** 8171,8177 ****
                item_type = vartype->tt_member;
            else if (vartype->tt_member->tt_type == VAR_LIST
                          && vartype->tt_member->tt_member->tt_type != VAR_ANY)
-               // TODO: should get the type for each lhs
                item_type = vartype->tt_member->tt_member;
        }
  
--- 8170,8175 ----
***************
*** 8224,8230 ****
                lhs_type = parse_type(&p, cctx->ctx_type_list, TRUE);
            }
  
!           // TODO: script var not supported?
            if (get_var_dest(name, &dest, CMD_for, &opt_flags,
                                              &vimvaridx, &type, cctx) == FAIL)
                goto failed;
--- 8222,8228 ----
                lhs_type = parse_type(&p, cctx->ctx_type_list, TRUE);
            }
  
!           // Script var is not supported.
            if (get_var_dest(name, &dest, CMD_for, &opt_flags,
                                              &vimvaridx, &type, cctx) == FAIL)
                goto failed;
***************
*** 8771,8791 ****
  #ifdef FEAT_PROFILE
        if (cctx->ctx_compile_type == CT_PROFILE
                && ((isn_T *)instr->ga_data)[this_instr - 1]
!                                                      .isn_type == 
ISN_PROF_START)
        {
            // jump to the profile start of the "finally"
            --this_instr;
  
            // jump to the profile end above it
            if (this_instr > 0 && ((isn_T *)instr->ga_data)[this_instr - 1]
!                                                        .isn_type == 
ISN_PROF_END)
                --this_instr;
        }
  #endif
  
        // Fill in the "end" label in jumps at the end of the blocks.
        compile_fill_jump_to_end(&scope->se_u.se_try.ts_end_label,
!                                                               this_instr, 
cctx);
  
        // If there is no :catch then an exception jumps to :finally.
        if (isn->isn_arg.try.try_ref->try_catch == 0)
--- 8769,8789 ----
  #ifdef FEAT_PROFILE
        if (cctx->ctx_compile_type == CT_PROFILE
                && ((isn_T *)instr->ga_data)[this_instr - 1]
!                                                  .isn_type == ISN_PROF_START)
        {
            // jump to the profile start of the "finally"
            --this_instr;
  
            // jump to the profile end above it
            if (this_instr > 0 && ((isn_T *)instr->ga_data)[this_instr - 1]
!                                                    .isn_type == ISN_PROF_END)
                --this_instr;
        }
  #endif
  
        // Fill in the "end" label in jumps at the end of the blocks.
        compile_fill_jump_to_end(&scope->se_u.se_try.ts_end_label,
!                                                            this_instr, cctx);
  
        // If there is no :catch then an exception jumps to :finally.
        if (isn->isn_arg.try.try_ref->try_catch == 0)
***************
*** 8800,8807 ****
        }
        if (generate_instr(cctx, ISN_FINALLY) == NULL)
            return NULL;
- 
-       // TODO: set index in ts_finally_label jumps
      }
  
      return arg;
--- 8798,8803 ----
***************
*** 9184,9192 ****
  
      if (eap->cmdidx == CMD_folddoopen || eap->cmdidx == CMD_folddoclosed)
      {
!       // TODO: should only expand when appropriate for the command
!       eap->arg = skiptowhite(eap->arg);
!       has_expr = TRUE;
      }
  
      if (has_expr && (p = (char_u *)strstr((char *)eap->arg, "`=")) != NULL)
--- 9180,9196 ----
  
      if (eap->cmdidx == CMD_folddoopen || eap->cmdidx == CMD_folddoclosed)
      {
!       exarg_T nea;
! 
!       CLEAR_FIELD(nea);
!       nea.cmd = eap->arg;
!       p = find_ex_command(&nea, NULL, lookup_scriptitem, NULL);
!       if (nea.cmdidx <= CMD_SIZE)
!       {
!           has_expr = excmd_get_argt(nea.cmdidx) & (EX_XFILE | EX_EXPAND);
!           if (has_expr)
!               eap->arg = skiptowhite(eap->arg);
!       }
      }
  
      if (has_expr && (p = (char_u *)strstr((char *)eap->arg, "`=")) != NULL)
*** ../vim-8.2.3708/src/testdir/test_vim9_cmd.vim       2021-11-30 
21:39:35.938026224 +0000
--- src/testdir/test_vim9_cmd.vim       2021-11-30 21:56:40.948563398 +0000
***************
*** 206,211 ****
--- 206,220 ----
    folddoclose edit `=name`
    assert_equal('xxx', bufname())
    bwipe!
+ 
+   var lines =<< trim END
+       g:val = 'value'
+       def Test()
+         folddoopen echo `=g:val`
+       enddef
+       call Test()
+   END
+   CheckScriptFailure(lines, 'E15: Invalid expression: "`=g:val`"')
  enddef
  
  def Test_hardcopy_wildcards()
*** ../vim-8.2.3708/src/version.c       2021-11-30 21:39:35.942026216 +0000
--- src/version.c       2021-11-30 21:50:57.329030992 +0000
***************
*** 755,756 ****
--- 755,758 ----
  {   /* Add new patch number below this line */
+ /**/
+     3709,
  /**/

-- 
Friends?  I have lots of friends!  In fact, I have all episodes ever made.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20211130215936.CD7711C2562%40moolenaar.net.

Raspunde prin e-mail lui