Always validate a macro definition

If a user-defined macro appears only in the argument of another
macro its definition is not validated and this leads to errors.

Fixes bug #12524.
This commit is contained in:
Enrico Forestieri 2022-05-31 22:13:52 +02:00
parent 5f8ba9387d
commit 0aad230154

View File

@ -967,23 +967,28 @@ void InsetMathMacro::validate(LaTeXFeatures & features) const
features.require(data->required()); features.require(data->required());
} }
if (name() == "binom") // Validate the cells and the definition.
features.require("binom"); // However, don't validate the definition if the macro is
// from the symbols file and has not been redefined, because
// validate the cells and the definition // in this case the definition is only used for screen display.
if (displayMode() == DISPLAY_NORMAL) { MathWordList const & words = mathedWordList();
// Don't update requirements if the macro comes from MathWordList::const_iterator it = words.find(name());
// the symbols file and has not been redefined. MacroNameSet macros;
MathWordList const & words = mathedWordList(); buffer().listMacroNames(macros);
MathWordList::const_iterator it = words.find(name()); if (it == words.end() || it->second.inset != "macro"
MacroNameSet macros; || macros.find(name()) != macros.end()) {
buffer().listMacroNames(macros); if (displayMode() == DISPLAY_NORMAL) {
if (it == words.end() || it->second.inset != "macro" d->definition_.validate(features);
|| macros.find(name()) != macros.end()) { } else if (displayMode() == DISPLAY_INIT) {
d->definition_.validate(features); MathData ar(const_cast<Buffer *>(&buffer()));
MacroData const * data = buffer().getMacro(name());
if (data) {
asArray(data->definition(), ar);
ar.validate(features);
}
} }
InsetMathNest::validate(features);
} }
InsetMathNest::validate(features);
} }