comparison src/vim9compile.c @ 20982:bb49b5090a9c v8.2.1042

patch 8.2.1042: Vim9: cannot put an operator on the next line Commit: https://github.com/vim/vim/commit/df069eec3b90401e880e9b0e258146d8f36c474d Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jun 22 23:02:51 2020 +0200 patch 8.2.1042: Vim9: cannot put an operator on the next line Problem: Vim9: cannot put an operator on the next line. Solution: Require a colon before a range to see if that causes problems.
author Bram Moolenaar <Bram@vim.org>
date Mon, 22 Jun 2020 23:15:04 +0200
parents d561e3c6cd65
children ae4b1d497a06
comparison
equal deleted inserted replaced
20981:6e0166b4443d 20982:bb49b5090a9c
641 if (!((type1 == VAR_NUMBER || type1 == VAR_FLOAT || type1 == VAR_ANY) 641 if (!((type1 == VAR_NUMBER || type1 == VAR_FLOAT || type1 == VAR_ANY)
642 && (type2 == VAR_NUMBER || type2 == VAR_FLOAT 642 && (type2 == VAR_NUMBER || type2 == VAR_FLOAT
643 || type2 == VAR_ANY))) 643 || type2 == VAR_ANY)))
644 { 644 {
645 if (*op == '+') 645 if (*op == '+')
646 emsg(_("E1035: wrong argument type for +")); 646 emsg(_("E1051: wrong argument type for +"));
647 else 647 else
648 semsg(_("E1036: %c requires number or float arguments"), *op); 648 semsg(_("E1036: %c requires number or float arguments"), *op);
649 return FAIL; 649 return FAIL;
650 } 650 }
651 return OK; 651 return OK;
6693 */ 6693 */
6694 for (;;) 6694 for (;;)
6695 { 6695 {
6696 exarg_T ea; 6696 exarg_T ea;
6697 int starts_with_colon = FALSE; 6697 int starts_with_colon = FALSE;
6698 char_u *cmd;
6698 6699
6699 // Bail out on the first error to avoid a flood of errors and report 6700 // Bail out on the first error to avoid a flood of errors and report
6700 // the right line number when inside try/catch. 6701 // the right line number when inside try/catch.
6701 if (emsg_before != called_emsg) 6702 if (emsg_before != called_emsg)
6702 goto erret; 6703 goto erret;
6851 } 6852 }
6852 6853
6853 /* 6854 /*
6854 * COMMAND after range 6855 * COMMAND after range
6855 */ 6856 */
6857 cmd = ea.cmd;
6856 ea.cmd = skip_range(ea.cmd, NULL); 6858 ea.cmd = skip_range(ea.cmd, NULL);
6859 if (ea.cmd > cmd && !starts_with_colon)
6860 {
6861 emsg(_(e_colon_required));
6862 goto erret;
6863 }
6857 p = find_ex_command(&ea, NULL, starts_with_colon ? NULL 6864 p = find_ex_command(&ea, NULL, starts_with_colon ? NULL
6858 : (void *(*)(char_u *, size_t, cctx_T *))lookup_local, 6865 : (void *(*)(char_u *, size_t, cctx_T *))lookup_local,
6859 &cctx); 6866 &cctx);
6860 6867
6861 if (p == ea.cmd && ea.cmdidx != CMD_SIZE) 6868 if (p == ea.cmd && ea.cmdidx != CMD_SIZE)
7006 case CMD_echomsg: 7013 case CMD_echomsg:
7007 case CMD_echoerr: 7014 case CMD_echoerr:
7008 line = compile_mult_expr(p, ea.cmdidx, &cctx); 7015 line = compile_mult_expr(p, ea.cmdidx, &cctx);
7009 break; 7016 break;
7010 7017
7018 // TODO: other commands with an expression argument
7019
7011 default: 7020 default:
7012 // TODO: other commands with an expression argument
7013 // Not recognized, execute with do_cmdline_cmd(). 7021 // Not recognized, execute with do_cmdline_cmd().
7014 ea.arg = p; 7022 ea.arg = p;
7015 line = compile_exec(line, &ea, &cctx); 7023 line = compile_exec(line, &ea, &cctx);
7016 break; 7024 break;
7017 } 7025 }