Error: defined but not used: 'this'

I get the following error:

error: defined but not used: ‘this’

With a module very similar to this:

module Main.Excp where

import Main.ErrorCode
import DA.Exception

exception Excp
  with
    errorCode: ErrorCode
  where
    message "Excp Exception: " <> show errorCode

What does this mean?

This comes from a warning that is not turned on by default, specifically -Wunused-matches (or a slightly different flag that also ends up enabling this one).

It’s a false positive here. this is in implicitly in scope in message (just like for templates) and you’re not using it so you get the warning. I’ll open an issue to fix that.

What I have found is:
The following pragma is needed until upstream issue gets resolved:
https://github.com/digital-asset/daml/issues/11004

{-# OPTIONS -Wno-unused-matches #-}

Oh good catch, I forgot we already had that issue.