Patch 8.2.1528
Problem:    Vim9: :endif not found after "if false".
Solution:   When skipping still check for a following command. (closes #6797)
Files:      src/vim9compile.c, src/testdir/test_vim9_script.vim


*** ../vim-8.2.1527/src/vim9compile.c   2020-08-23 19:34:44.722827763 +0200
--- src/vim9compile.c   2020-08-27 22:42:29.184217967 +0200
***************
*** 4014,4019 ****
--- 4014,4026 ----
      int               ppconst_used = ppconst->pp_used;
      char_u    *next;
  
+     // Ignore all kinds of errors when not producing code.
+     if (cctx->ctx_skip == SKIP_YES)
+     {
+       skip_expr(arg);
+       return OK;
+     }
+ 
      // Evaluate the first expression.
      if (compile_expr2(arg, cctx, ppconst) == FAIL)
        return FAIL;
***************
*** 6724,6741 ****
  
        p = skipwhite(p);
  
!       if (cctx.ctx_skip == SKIP_YES
!               && ea.cmdidx != CMD_if
                && ea.cmdidx != CMD_elseif
                && ea.cmdidx != CMD_else
-               && ea.cmdidx != CMD_endif)
-       {
-           line = (char_u *)"";
-           continue;
-       }
- 
-       if (ea.cmdidx != CMD_elseif
-               && ea.cmdidx != CMD_else
                && ea.cmdidx != CMD_endif
                && ea.cmdidx != CMD_endfor
                && ea.cmdidx != CMD_endwhile
--- 6731,6739 ----
  
        p = skipwhite(p);
  
!       if (cctx.ctx_had_return
                && ea.cmdidx != CMD_elseif
                && ea.cmdidx != CMD_else
                && ea.cmdidx != CMD_endif
                && ea.cmdidx != CMD_endfor
                && ea.cmdidx != CMD_endwhile
***************
*** 6743,6753 ****
                && ea.cmdidx != CMD_finally
                && ea.cmdidx != CMD_endtry)
        {
!           if (cctx.ctx_had_return)
!           {
!               emsg(_(e_unreachable_code_after_return));
!               goto erret;
!           }
        }
  
        switch (ea.cmdidx)
--- 6741,6748 ----
                && ea.cmdidx != CMD_finally
                && ea.cmdidx != CMD_endtry)
        {
!           emsg(_(e_unreachable_code_after_return));
!           goto erret;
        }
  
        switch (ea.cmdidx)
***************
*** 6845,6851 ****
                    if (compile_expr0(&p, &cctx) == FAIL)
                        goto erret;
  
!                   // drop the return value
                    generate_instr_drop(&cctx, ISN_DROP, 1);
  
                    line = skipwhite(p);
--- 6840,6846 ----
                    if (compile_expr0(&p, &cctx) == FAIL)
                        goto erret;
  
!                   // drop the result
                    generate_instr_drop(&cctx, ISN_DROP, 1);
  
                    line = skipwhite(p);
***************
*** 6859,6865 ****
                    line = compile_mult_expr(p, ea.cmdidx, &cctx);
                    break;
  
!           // TODO: other commands with an expression argument
  
            case CMD_append:
            case CMD_change:
--- 6854,6860 ----
                    line = compile_mult_expr(p, ea.cmdidx, &cctx);
                    break;
  
!           // TODO: any other commands with an expression argument?
  
            case CMD_append:
            case CMD_change:
***************
*** 6870,6877 ****
                    goto erret;
  
            case CMD_SIZE:
!                   semsg(_(e_invalid_command_str), ea.cmd);
!                   goto erret;
  
            default:
                    // Not recognized, execute with do_cmdline_cmd().
--- 6865,6878 ----
                    goto erret;
  
            case CMD_SIZE:
!                   if (cctx.ctx_skip != SKIP_YES)
!                   {
!                       semsg(_(e_invalid_command_str), ea.cmd);
!                       goto erret;
!                   }
!                   // We don't check for a next command here.
!                   line = (char_u *)"";
!                   break;
  
            default:
                    // Not recognized, execute with do_cmdline_cmd().
*** ../vim-8.2.1527/src/testdir/test_vim9_script.vim    2020-08-27 
21:33:06.982960742 +0200
--- src/testdir/test_vim9_script.vim    2020-08-27 22:41:25.236474721 +0200
***************
*** 2122,2127 ****
--- 2122,2135 ----
      res = true
    endif
    assert_equal(false, res)
+ 
+   # with constant "false" expression may be invalid so long as the syntax is 
OK
+   if false | eval 0 | endif
+   if false | eval burp + 234 | endif
+   if false | echo burp 234 'asd' | endif
+   if false
+     burp
+   endif
  enddef
  
  def Test_if_const_expr_fails()
*** ../vim-8.2.1527/src/version.c       2020-08-27 21:33:06.982960742 +0200
--- src/version.c       2020-08-27 22:33:48.794443202 +0200
***************
*** 756,757 ****
--- 756,759 ----
  {   /* Add new patch number below this line */
+ /**/
+     1528,
  /**/

-- 
Facepalm statement #4: "3000 year old graves?  That's not possible, it's only
2014!"

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            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/202008272043.07RKhTRL2051964%40masaka.moolenaar.net.

Raspunde prin e-mail lui