daml icon indicating copy to clipboard operation
daml copied to clipboard

False positive warning on unused let

Open leonidr-da opened this issue 4 years ago • 1 comments

Given

module Main where

template Asset
  with
    issuer : Party
    owner  : Party
    name   : Text
  where
    signatory owner
    let p = (issuer, name)

    controller owner can
      TellMeAboutP : ()
        do
          debug $ show p
      GiveMeP : (Party, Text)
        do
          return p

compiled with build-options: [ "--ghc-option", "-Wunused-local-binds" ] results in:

daml build
Compiling o to a DAR.
File:     daml/Main.daml
Hidden:   no
Range:    1:1-1:1
Source:   typecheck
Severity: DsWarning
Message:  daml/Main.daml:1:1: warning: Defined but not used: ‘p’
File:     daml/Main.daml
Hidden:   no
Range:    1:1-1:1
Source:   typecheck
Severity: DsWarning
Message:  daml/Main.daml:1:1: warning: Defined but not used: ‘p’
File:     daml/Main.daml
Hidden:   no
Range:    10:5-10:20
Source:   typecheck
Severity: DsWarning
Message:  daml/Main.daml:10:5: warning: Defined but not used: ‘p’
File:     daml/Main.daml
Hidden:   no
Range:    13:16-13:21
Source:   typecheck
Severity: DsWarning
Message:  daml/Main.daml:13:16: warning: Defined but not used: ‘p’
Created .daml/dist/o-0.0.1.dar

leonidr-da avatar Sep 06 '21 15:09 leonidr-da

I encountered this same issue and it appears to happen whenever a let binding is declared within a template, but outside of any choice. @leonidr-da and I are actually both working on a project where it's relevant, so if we can bump the priority a bit, that would be helpful.

HectorAE avatar Jul 18 '22 15:07 HectorAE