LaTeXML icon indicating copy to clipboard operation
LaTeXML copied to clipboard

perl warnings when mouth has no source

Open xworld21 opened this issue 11 months ago • 2 comments

On occasion, the mouth does not have a defined source, so this call https://github.com/brucemiller/LaTeXML/blob/f82b733eade2c81f24567c349929f2a696cb66cb/lib/LaTeXML/Package.pm#L1625 creates annoying perl warnings about using undefined values in strings.

Quick fix is to patch getSource to return an empty string when not defined. Undefined sources seem intentional, given the commit message 'to make it much easier to programatically acces if a source is anonymous or not' at https://github.com/brucemiller/LaTeXML/blob/f82b733eade2c81f24567c349929f2a696cb66cb/lib/LaTeXML/Core/Mouth.pm#L58 but empty strings would do that just fine.

xworld21 avatar Jan 01 '25 11:01 xworld21

This is easy to silence with just adding ->getSource || '' to that Package.pm line.

But are we sure the warnings are meaningless / come in a healthy setting? Some example where they get emitted could be helpful to see if any changes to Mouth itself are necessary.

dginev avatar Jan 08 '25 19:01 dginev

in a healthy setting

Is raw beamer healthy? Probably not!

It's easier to look at the uses of getSource because there are only two of them. DefMathI uses it for 'introspection' and doesn't distinguish between defined and undefined source. State uses it to check if the file extension is tex or bib. So at the moment there is no reason for having getSource optional string as opposed to always a string.

(Further detail: Mouth->create sets an empty string for literal: and for undefined sources; Mouth->openString leaves the source undefined. The distinction seems accidental.)

xworld21 avatar Jan 08 '25 19:01 xworld21