Incorrect LuaTeX ligatures

The TeX ligatures are being mis-applied, you can use fontspec to turn them off, although for example that means that --- would no longer ligature to an mdash.

\documentclass[a4paper, 12pt]{article}
\usepackage{fontspec}
\def\czechSingleQuotes #1{‚#1‘} % UTF-8 chars for single quotes
\defaultfontfeatures[\rmfamily]{}
\setmainfont{Latin Modern Roman}
\begin{document}
\czechSingleQuotes{Ahoj!}

\czechSingleQuotes{Nazdar?}

‚Hi!‘
\end{document}

enter image description here


This is a luaotfload issue as this plain tex test shows, I'll report to the github.

enter image description here

\input{luaotfload.sty}

\font\fa=[lmroman12-regular.otf]
\font\fb=[lmroman12-regular.otf]:+tlig

\fa 

U+2018 no tlig !‘

U+0060 no tlig !`

\fb

U+2018 tlig !‘

U+0060  tlig !`

\bye

As David Carlisle has pointed out in comment, the "classic" TeX ligatures for inverted question and exclamation marks are being applied even though "typographic" quotes, rather than basic back quotes, are present.

Inserting the instruction \kern0pt before the closing quote is an effective remedy. Note that LuaTeX, unlike pdfLaTEX, discards {} elements. Hence, you can't use {} to create some invisible separation between the punctuation marks and the typographic quotes.

enter image description here

\documentclass{article}
\def\czechSingleQuotes#1{‚#1\kern0pt‘} % UTF8 chars for single quotes
\begin{document}
% "classic" TeX ligatures applied even though "typographic" quotes are in use
? ?` ?‘ --- ! !` !‘ 

\czechSingleQuotes{Ahoj!}

\czechSingleQuotes{Nazdar?}

\czechSingleQuotes{Hi!!}
\end{document}