digital-asset / daml

The Daml smart contract language
https://www.digitalasset.com/developers
797 stars 199 forks source link

False positive warning on unused let #10790

Open leonidr-da opened 3 years ago

leonidr-da commented 3 years ago

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
HectorAE commented 2 years ago

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.