haskell-mode
haskell-mode copied to clipboard
QuasiQuote submode handling produces many warnings
I've just spent hours tracking down prolific errors like the following, which occur only when editing certain Haskell files:
Invalid face reference: nil [2 times]
Invalid face reference: 1
Invalid face reference: nil [4 times]
Invalid face reference: 1888
Invalid face reference: 1
Invalid face reference: nil
Invalid face reference: 2100
Invalid face reference: nil [2 times]
Invalid face reference: 1
Invalid face reference: nil [4 times]
Invalid face reference: 2100
Invalid face reference: 1
Invalid face reference: nil
Invalid face reference: 2343
Invalid face reference: nil [2 times]
Invalid face reference: 1
Invalid face reference: nil [4 times]
Invalid face reference: 2343
Invalid face reference: 1
Invalid face reference: nil
Invalid face reference: 1119
Invalid face reference: nil [2 times]
Invalid face reference: 1
Invalid face reference: nil [4 times]
Invalid face reference: 1119
Invalid face reference: 1
Invalid face reference: nil
Invalid face reference: 1888
Invalid face reference: nil [2 times]
Invalid face reference: 1
Invalid face reference: nil [4 times]
Invalid face reference: 1888
Invalid face reference: 1
Invalid face reference: nil
Invalid face reference: 2100
Invalid face reference: nil [2 times]
Invalid face reference: 1
Invalid face reference: nil [4 times]
Invalid face reference: 2100
Invalid face reference: 1
Invalid face reference: nil
Invalid face reference: 2343
Invalid face reference: nil [2 times]
Invalid face reference: 1
Invalid face reference: nil [4 times]
Invalid face reference: 2343
Invalid face reference: 1
I discovered that the cause is that haskell-syntactic-face-function
does not conform with the behaviour expected of a font-lock-syntactic-face-function
, because those functions must always return a face name.
Particularly in the case of quasiquoting, where the quasiquote is recognised as a member of haskell-font-lock-quasi-quote-modes
, the function hands off propertization to the language mode (e.g. sql-mode
) before deliberately returning nil
. Indeed, to return anything else overrides the sub-mode's work.
So it seems like we're abusing syntactic faces, and should find another approach. However, I'm not sure of the best solution.
(Observed in both Emacs 25.3 and 26/27 development snapshots: I haven't tested with older versions.)
Is there a workaround to suppress these warnings? I've been driven crazy by this, it made it hard to debug an unrelated issue.
Is there a workaround to suppress these warnings? I've been driven crazy by this, it made it hard to debug an unrelated issue.
Yes, this should do the trick:
(setq haskell-font-lock-quasi-quote-modes nil)
I wonder if we should actually just strip out this functionality. Users can always use mmm-mode
or similar to handle quasiquoted regions, and that is rather more battle-tested in general.