Illegal instance declaration on "module"

Hi, I am getting this error on module
Any help would be greatly appreciated!

    • Illegal instance declaration for
        ‘HasExercise PaymentClaim Receive (contractId Receipt)’
        The coverage condition fails in class ‘HasExercise’
          for functional dependency: ‘t c -> r’
        Reason: lhs types ‘PaymentClaim’, ‘Receive’
          do not jointly determine rhs type ‘contractId Receipt’
        Un-determined variable: contractId
    • In the instance declaration for
        ‘HasExercise PaymentClaim Receive (contractId Receipt)’typecheck
    • Illegal instance declaration for
        ‘HasFromAnyChoice PaymentClaim Receive (contractId Receipt)’
       the coverage condition fails in class ‘HasFromAnyChoice’
          for functional dependency: ‘t c -> r’
        Reason: lhs types ‘PaymentClaim’, ‘Receive’
          do not jointly determine rhs type ‘contractId Receipt’
        Un-determined variable: contractId
    • In the instance declaration for
        ‘HasFromAnyChoice PaymentClaim Receive (contractId Receipt)’typecheck
    • Illegal instance declaration for
        ‘HasToAnyChoice PaymentClaim Receive (contractId Receipt)’
        The coverage condition fails in class ‘HasToAnyChoice’
           for functional dependency: ‘t c -> r’
        Reason: lhs types ‘PaymentClaim’, ‘Receive’
          do not jointly determine rhs type ‘contractId Receipt’
        Un-determined variable: contractId
    • In the instance declaration for
        ‘HasToAnyChoice PaymentClaim Receive (contractId Receipt)’typecheck


module Payment where

template Payable
    with
        amount: Decimal
        currency: Text
        from: Party
        to: Party
        reference: Text
    where
        signatory from

        choice ClaimPaid: ContractId PaymentClaim
            with 
                transactionId: Text 
            controller from
            do 
                create PaymentClaim with ..


template PaymentClaim
    with 
        amount: Decimal
        currency: Text
        from: Party
        to: Party
        reference: Text
        transactionId: Text
    where
        signatory from

        choice Receive: contractId Receipt
            controller to
            do  
                received <- getTime
                create Receipt
                    with ..

template Receipt
    with    
        amount: Decimal
        currency: Text
        from: Party
        to: Party
        reference: Text
        transactionId: Text
        received: Time
    where
        signatory to, from 

        choice Dismiss: ()
            controller from 
            do return  ()
                
1 Like

Hi @ktreply,

The issue here is that you used lower-case contractId instead of ContractId. As a general rule, in Daml lower-case type names refer to type variables whereas uppercase type names refer to concrete type (constructors) like ContractId.

3 Likes