Mercurial > vim
comparison src/vim9compile.c @ 21957:4343657b49fa v8.2.1528
patch 8.2.1528: Vim9: :endif not found after "if false"
Commit: https://github.com/vim/vim/commit/3988f64f9d512fd809d4a600b020638bf2c7d7ec
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Aug 27 22:43:03 2020 +0200
patch 8.2.1528: Vim9: :endif not found after "if false"
Problem: Vim9: :endif not found after "if false".
Solution: When skipping still check for a following command. (closes https://github.com/vim/vim/issues/6797)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 27 Aug 2020 22:45:03 +0200 |
parents | b931df03adcc |
children | 67d4be2757b0 |
comparison
equal
deleted
inserted
replaced
21956:40078db932ef | 21957:4343657b49fa |
---|---|
4011 compile_expr1(char_u **arg, cctx_T *cctx, ppconst_T *ppconst) | 4011 compile_expr1(char_u **arg, cctx_T *cctx, ppconst_T *ppconst) |
4012 { | 4012 { |
4013 char_u *p; | 4013 char_u *p; |
4014 int ppconst_used = ppconst->pp_used; | 4014 int ppconst_used = ppconst->pp_used; |
4015 char_u *next; | 4015 char_u *next; |
4016 | |
4017 // Ignore all kinds of errors when not producing code. | |
4018 if (cctx->ctx_skip == SKIP_YES) | |
4019 { | |
4020 skip_expr(arg); | |
4021 return OK; | |
4022 } | |
4016 | 4023 |
4017 // Evaluate the first expression. | 4024 // Evaluate the first expression. |
4018 if (compile_expr2(arg, cctx, ppconst) == FAIL) | 4025 if (compile_expr2(arg, cctx, ppconst) == FAIL) |
4019 return FAIL; | 4026 return FAIL; |
4020 | 4027 |
6722 } | 6729 } |
6723 } | 6730 } |
6724 | 6731 |
6725 p = skipwhite(p); | 6732 p = skipwhite(p); |
6726 | 6733 |
6727 if (cctx.ctx_skip == SKIP_YES | 6734 if (cctx.ctx_had_return |
6728 && ea.cmdidx != CMD_if | |
6729 && ea.cmdidx != CMD_elseif | 6735 && ea.cmdidx != CMD_elseif |
6730 && ea.cmdidx != CMD_else | |
6731 && ea.cmdidx != CMD_endif) | |
6732 { | |
6733 line = (char_u *)""; | |
6734 continue; | |
6735 } | |
6736 | |
6737 if (ea.cmdidx != CMD_elseif | |
6738 && ea.cmdidx != CMD_else | 6736 && ea.cmdidx != CMD_else |
6739 && ea.cmdidx != CMD_endif | 6737 && ea.cmdidx != CMD_endif |
6740 && ea.cmdidx != CMD_endfor | 6738 && ea.cmdidx != CMD_endfor |
6741 && ea.cmdidx != CMD_endwhile | 6739 && ea.cmdidx != CMD_endwhile |
6742 && ea.cmdidx != CMD_catch | 6740 && ea.cmdidx != CMD_catch |
6743 && ea.cmdidx != CMD_finally | 6741 && ea.cmdidx != CMD_finally |
6744 && ea.cmdidx != CMD_endtry) | 6742 && ea.cmdidx != CMD_endtry) |
6745 { | 6743 { |
6746 if (cctx.ctx_had_return) | 6744 emsg(_(e_unreachable_code_after_return)); |
6747 { | 6745 goto erret; |
6748 emsg(_(e_unreachable_code_after_return)); | |
6749 goto erret; | |
6750 } | |
6751 } | 6746 } |
6752 | 6747 |
6753 switch (ea.cmdidx) | 6748 switch (ea.cmdidx) |
6754 { | 6749 { |
6755 case CMD_def: | 6750 case CMD_def: |
6843 | 6838 |
6844 case CMD_eval: | 6839 case CMD_eval: |
6845 if (compile_expr0(&p, &cctx) == FAIL) | 6840 if (compile_expr0(&p, &cctx) == FAIL) |
6846 goto erret; | 6841 goto erret; |
6847 | 6842 |
6848 // drop the return value | 6843 // drop the result |
6849 generate_instr_drop(&cctx, ISN_DROP, 1); | 6844 generate_instr_drop(&cctx, ISN_DROP, 1); |
6850 | 6845 |
6851 line = skipwhite(p); | 6846 line = skipwhite(p); |
6852 break; | 6847 break; |
6853 | 6848 |
6857 case CMD_echomsg: | 6852 case CMD_echomsg: |
6858 case CMD_echoerr: | 6853 case CMD_echoerr: |
6859 line = compile_mult_expr(p, ea.cmdidx, &cctx); | 6854 line = compile_mult_expr(p, ea.cmdidx, &cctx); |
6860 break; | 6855 break; |
6861 | 6856 |
6862 // TODO: other commands with an expression argument | 6857 // TODO: any other commands with an expression argument? |
6863 | 6858 |
6864 case CMD_append: | 6859 case CMD_append: |
6865 case CMD_change: | 6860 case CMD_change: |
6866 case CMD_insert: | 6861 case CMD_insert: |
6867 case CMD_t: | 6862 case CMD_t: |
6868 case CMD_xit: | 6863 case CMD_xit: |
6869 not_in_vim9(&ea); | 6864 not_in_vim9(&ea); |
6870 goto erret; | 6865 goto erret; |
6871 | 6866 |
6872 case CMD_SIZE: | 6867 case CMD_SIZE: |
6873 semsg(_(e_invalid_command_str), ea.cmd); | 6868 if (cctx.ctx_skip != SKIP_YES) |
6874 goto erret; | 6869 { |
6870 semsg(_(e_invalid_command_str), ea.cmd); | |
6871 goto erret; | |
6872 } | |
6873 // We don't check for a next command here. | |
6874 line = (char_u *)""; | |
6875 break; | |
6875 | 6876 |
6876 default: | 6877 default: |
6877 // Not recognized, execute with do_cmdline_cmd(). | 6878 // Not recognized, execute with do_cmdline_cmd(). |
6878 ea.arg = p; | 6879 ea.arg = p; |
6879 line = compile_exec(line, &ea, &cctx); | 6880 line = compile_exec(line, &ea, &cctx); |