I followed QA_1.
I use vim 9.1.0 instead of nvim which seems to also have the following bug and I have the following in foo.vim at line 67:
if g:LOG_MSG==v:true | echow "g:mode_class " | else | echo "" | endif
Here when g:LOG_MSG=v:true it will echow "g:mode_class " and all is fine. But when g:LOG_MSG=v:false, it will throw line 92: E171: Missing :endif (Notice it is at line 92 instead of 67). And when I do :if g:LOG_MSG==v:true | echow "g:mode_class " | else | echo "" | endif in the command mode it works all well.
By QA_2, here echow may be probably not the source of this problem.
IMHO, it is probably due to if v:false will skip all the following in that line. And multi-line if else endif block works.
The minimal reproduction:
$ cat ~/.vim/tmp/if_endif.vim
if v:false | echow "g:mode_class " | else | echo "" | endif
$ echo "" > ~/.tmp.vimrc;vim --noplugin -u ~/.tmp.vimrc -c ":source ~/.vim/tmp/if_endif.vim"
Error detected while processing command line..script /c/Users/czg/.vim/tmp/if_endif.vim:
line 2:
E171: Missing :endif
Q:
How to make if else endif oneliner work in VIM?