# Error: defined but not used: 'this'

**URL:** <https://forum.canton.network/t/error-defined-but-not-used-this/3843>\
**Category:** App Development\
**Tags:** daml\
**Created:** [February 3, 2022, 9:04am UTC](https://forum.canton.network/t/error-defined-but-not-used-this/3843 "2022-02-03T09:04:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gaborh](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gaborh/32/177_2.png) [@gaborh](https://forum.canton.network/u/gaborh)\
**Post date:** [February 3, 2022, 9:04am UTC](https://forum.canton.network/t/error-defined-but-not-used-this/3843/1 "2022-02-03T09:04:38Z")

</div>

I get the following error:

> error: defined but not used: ‘this’

With a module very similar to this:

```haskell
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?

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [February 3, 2022, 9:24am UTC](https://forum.canton.network/t/error-defined-but-not-used-this/3843/2 "2022-02-03T09:24:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![gaborh](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gaborh/32/177_2.png) [@gaborh](https://forum.canton.network/u/gaborh)\
**Post date:** [February 3, 2022, 9:24am UTC](https://forum.canton.network/t/error-defined-but-not-used-this/3843/3 "2022-02-03T09:24:41Z")

</div>

What I have found is:  
The following pragma is needed until upstream issue gets resolved:  
[https://github.com/digital-asset/daml/issues/11004](https://protect-us.mimecast.com/s/xbOYCo2mK9CZMOET1ZPjB?domain=github.com)

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

```

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [February 3, 2022, 9:25am UTC](https://forum.canton.network/t/error-defined-but-not-used-this/3843/4 "2022-02-03T09:25:07Z")

</div>

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