@@ -4014,6 +4014,13 @@ compile_expr1(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
40144014 int ppconst_used = ppconst -> pp_used ;
40154015 char_u * next ;
40164016
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+ }
4023+
40174024 // Evaluate the first expression.
40184025 if (compile_expr2 (arg , cctx , ppconst ) == FAIL )
40194026 return FAIL ;
@@ -6724,17 +6731,8 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
67246731
67256732 p = skipwhite (p );
67266733
6727- if (cctx .ctx_skip == SKIP_YES
6728- && ea .cmdidx != CMD_if
6734+ if (cctx .ctx_had_return
67296735 && 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
67386736 && ea .cmdidx != CMD_else
67396737 && ea .cmdidx != CMD_endif
67406738 && ea .cmdidx != CMD_endfor
@@ -6743,11 +6741,8 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
67436741 && ea .cmdidx != CMD_finally
67446742 && ea .cmdidx != CMD_endtry )
67456743 {
6746- if (cctx .ctx_had_return )
6747- {
6748- emsg (_ (e_unreachable_code_after_return ));
6749- goto erret ;
6750- }
6744+ emsg (_ (e_unreachable_code_after_return ));
6745+ goto erret ;
67516746 }
67526747
67536748 switch (ea .cmdidx )
@@ -6845,7 +6840,7 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
68456840 if (compile_expr0 (& p , & cctx ) == FAIL )
68466841 goto erret ;
68476842
6848- // drop the return value
6843+ // drop the result
68496844 generate_instr_drop (& cctx , ISN_DROP , 1 );
68506845
68516846 line = skipwhite (p );
@@ -6859,7 +6854,7 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
68596854 line = compile_mult_expr (p , ea .cmdidx , & cctx );
68606855 break ;
68616856
6862- // TODO: other commands with an expression argument
6857+ // TODO: any other commands with an expression argument?
68636858
68646859 case CMD_append :
68656860 case CMD_change :
@@ -6870,8 +6865,14 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
68706865 goto erret ;
68716866
68726867 case CMD_SIZE :
6873- semsg (_ (e_invalid_command_str ), ea .cmd );
6874- goto erret ;
6868+ if (cctx .ctx_skip != SKIP_YES )
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 ;
68756876
68766877 default :
68776878 // Not recognized, execute with do_cmdline_cmd().
0 commit comments