# Error when using selnolig and lua-check-hyphen: attempt to index global 'debug' (a boolean value)

\documentclass{article}
\usepackage{fontspec} % required for selnolig
\usepackage{selnolig}
\usepackage{lua-check-hyphen}
\begin{document}
Foo
\end{document}


Using my two favorite lualatex packages as demonstrated above, I get an error:

! LuaTeX error ...es (x86)/MiKTeX/2.9/tex/luatex/lualibs/lualibs-table.lua:14: a
ttempt to index global 'debug' (a boolean value).
\lltxb@requirelua ...xluaescapestring {#2}" \fi )}

l.26 \RequirePackage
{metalogo}


Is there a way to avoid this error or perhaps even to fix one of the packages?

Interestingly, if you switch the order of the packages and load selnolig last, no error occurs. But that’s not really the kind of solution I’m looking for …

• Could you say why that's not an acceptable solution? Note that I don't have any idea what these packages do so maybe it is obvious. I ask because 'load X before Y rather than Y before X' is such a common solution to LaTeX problems that I assume there must be some special reason to rule it out. – cfr Sep 21 '14 at 2:12
• @cfr You’re right, if it turns out that things are exactly the way they should be, then the obligatory loading order is the answer (and should probably be put in the respective documentations). I guess I’m expecting/hoping for there to be a solution that would lead to a change in one of the packages and make the loading order irrelevant. Btw, (Mico’s) selnolig suppresses unwanted ligatures at morpheme boundaries, and (Patrick’s/topskip’s) lua-check-hyphen creates an auxiliary file with all hyphenated words in your document. I use both for the final compilation. – doncherry Sep 21 '14 at 12:22
• In terms of order, I’d hope that the hyphenation-list is created after the ligatures are removed, in the presumably rare case the de-ligaturization results in different hyphenation. – doncherry Sep 21 '14 at 12:26
• Just noticed your posting. I haven't checked Patrick's code in detail, so the following is mostly an educated guess for now: Both packages may be using a global lua variable named debug. (I know selnolig does...) If that's indeed the root cause of the conflict, the best solution is for one or the other package (or both...) to choose variable names that don't conflict with those used by other packages. I'll put this on my to-do list for selnolig's next version. – Mico Nov 22 '14 at 19:17
• I get no error with tl2018. Imho the question could be closed. – Ulrike Fischer Jun 21 '18 at 20:27