<!DOCTYPE html><html><head><title></title><style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><div style="font-family:Arial;">Here is another possible small bug in the otherwise excellent `luamplib` implementation of Metapost. Consider this minimal program:<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">prologues := 3;<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">outputtemplate := "%j%c.%{outputformat}";<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">beginfig(1);<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> label(mpversion, origin);<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> label("", 10 up);<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">endfig;<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">end.</span><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">This compiles without error and produces a tiny eps file saying "2.00" and gives this log<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">This is MetaPost, version 2.00 (TeX Live 2021) (kpathsea version 6.3.3) 15 SEP 2021 21:14<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">**bug.mp<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">(/usr/local/texlive/2021/texmf-dist/metapost/base/mpost.mp<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">(/usr/local/texlive/2021/texmf-dist/metapost/base/plain.mp<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">Preloading the plain mem file, version 1.005) ) (./bug.mp [1{psfonts.map}<cmr10<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">.pfb>] )<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">1 output file written: bug1.eps<br></span></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">If I wrap this up in luamplib like this<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">\documentclass{standalone}<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">\usepackage{luamplib}<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">\begin{document}<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">\begin{mplibcode}<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">beginfig(1);<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> label(mpversion, origin);<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> label("", 10 up);<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">endfig;<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">\end{mplibcode}<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">\end{document}</span><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">it also compiles without error and produces a tiny PDF saying "2.00". But if I add the textext option like this:<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">\documentclass{standalone}<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">\usepackage{luamplib}<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">\begin{document}<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">\mplibtextextlabel{enable}<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">\begin{mplibcode}<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">beginfig(1);<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> label(mpversion, origin);<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"> label("", 10 up);<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">endfig;<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">\end{mplibcode}<br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">\end{document}</span><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">Then it fails with an error, no output it produced, and I see this in the log</div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">...texlive/2021/texmf-dist/tex/luatex/luamplib/luamplib.lua:22: bad argument #2 </span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">to 'format' (no value)</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">stack traceback:</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">[C]: in function 'string.format'</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">...texlive/2021/texmf-dist/tex/luatex/luamplib/luamplib.lua:22: in upvalue 'war</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">n'</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">...texlive/2021/texmf-dist/tex/luatex/luamplib/luamplib.lua:257: in upvalue 're</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">porterror'</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">...texlive/2021/texmf-dist/tex/luatex/luamplib/luamplib.lua:313: in function <.</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">..texlive/2021/texmf-dist/tex/luatex/luamplib/luamplib.lua:309></span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">(...tail calls...)</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">...texlive/2021/texmf-dist/tex/luatex/luamplib/luamplib.lua:656: in field 'proc</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">ess_mplibcode'</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">[\directlua]:1: in main chunk.</span><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><br></span></div><div style="font-family:Arial;"><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;"><inserted text> BAD</span><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">Obviously I can avoid the error by *not* using an empty string, but since it works with plain MP it was a bit surprising that the textext option trips over it. The original use case was an if ... else ... fi block in a loop where I only wanted a label for some values of the loop variable.<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">- In luamplib, I get the same error if I put TEX("") or textext("").<br></div><div style="font-family:Arial;">- In plain MP with input TEX there is no error with TEX("")</div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">thanks and best wishes, Toby Thurston<br></div><div style="font-family:Arial;"> <br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;"><br></div></body></html>