@@ -2387,27 +2387,32 @@ eval0_retarg(
23872387
23882388 p = skipwhite (arg );
23892389 ret = eval1 (& p , rettv , evalarg );
2390- expr_end = p ;
2391- p = skipwhite (p );
23922390
2393- // In Vim9 script a command block is not split at NL characters for
2394- // commands using an expression argument. Skip over a '#' comment to check
2395- // for a following NL. Require white space before the '#'.
2396- if (in_vim9script () && p > expr_end && retarg == NULL )
2397- while (* p == '#' )
2398- {
2399- char_u * nl = vim_strchr (p , NL );
2391+ if (ret != FAIL )
2392+ {
2393+ expr_end = p ;
2394+ p = skipwhite (p );
24002395
2401- if (nl == NULL )
2402- break ;
2403- p = skipwhite (nl + 1 );
2404- if (eap != NULL && * p != NUL )
2405- eap -> nextcmd = p ;
2406- check_for_end = FALSE;
2407- }
2396+ // In Vim9 script a command block is not split at NL characters for
2397+ // commands using an expression argument. Skip over a '#' comment to
2398+ // check for a following NL. Require white space before the '#'.
2399+ if (in_vim9script () && p > expr_end && retarg == NULL )
2400+ while (* p == '#' )
2401+ {
2402+ char_u * nl = vim_strchr (p , NL );
2403+
2404+ if (nl == NULL )
2405+ break ;
2406+ p = skipwhite (nl + 1 );
2407+ if (eap != NULL && * p != NUL )
2408+ eap -> nextcmd = p ;
2409+ check_for_end = FALSE;
2410+ }
2411+
2412+ if (check_for_end )
2413+ end_error = !ends_excmd2 (arg , p );
2414+ }
24082415
2409- if (ret != FAIL && check_for_end )
2410- end_error = !ends_excmd2 (arg , p );
24112416 if (ret == FAIL || end_error )
24122417 {
24132418 if (ret != FAIL )
@@ -2433,7 +2438,8 @@ eval0_retarg(
24332438 // Some of the expression may not have been consumed. Do not check for
24342439 // a next command to avoid more errors, unless "|" is following, which
24352440 // could only be a command separator.
2436- if (eap != NULL && skipwhite (p )[0 ] == '|' && skipwhite (p )[1 ] != '|' )
2441+ if (eap != NULL && p != NULL
2442+ && skipwhite (p )[0 ] == '|' && skipwhite (p )[1 ] != '|' )
24372443 eap -> nextcmd = check_nextcmd (p );
24382444 return FAIL ;
24392445 }
0 commit comments