14

Have you encountered this error? IDE complains that the validator is not INLINABLE, while it actually is:

Program error: GHC Core to PLC plugin: E043:Error: Reference to a name which is not a local, a builtin, or an external INLINABLE function: Variable GHC.Base..
            No unfolding
Context: Compiling expr: GHC.Base..
Context: Compiling expr: GHC.Base..
                           @ (Plutus.V1.Ledger.Contexts.ScriptContext -> GHC.Types.Bool)
Context: Compiling expr: GHC.Base..
                           @ (Plutus.V1.Ledger.Contexts.ScriptContext -> GHC.Types.Bool)
                           @ Ledger.Typed.Scripts.Validators.WrappedMonetaryPolicyType
Context: Compiling expr: GHC.Base..
                           @ (Plutus.V1.Ledger.Contexts.ScriptContext -> GHC.Types.Bool)
                           @ Ledger.Typed.Scripts.Validators.WrappedMonetaryPolicyType
                           @ Plutus.V1.Ledger.Value.TokenName
Context: Compiling expr: GHC.Base..
                           @ (Plutus.V1.Ledger.Contexts.ScriptContext -> GHC.Types.Bool)
                           @ Ledger.Typed.Scripts.Validators.WrappedMonetaryPolicyType
                           @ Plutus.V1.Ledger.Value.TokenName
                           Ledger.Typed.Scripts.Validators.wrapMonetaryPolicy
Context: Compiling expr: GHC.Base..
                           @ (Plutus.V1.Ledger.Contexts.ScriptContext -> GHC.Types.Bool)
                           @ Ledger.Typed.Scripts.Validators.WrappedMonetaryPolicyType
                           @ Plutus.V1.Ledger.Value.TokenName
                           Ledger.Typed.Scripts.Validators.wrapMonetaryPolicy
                           Plutus.Contracts.FungibleToken.validator
Context: Compiling expr at "main:Plutus.Contracts.FungibleToken:(19,6)-(19,69)"

Module I'm trying to use IDE in:

{-# LANGUAGE DataKinds       #-}
{-# LANGUAGE TemplateHaskell #-}

module Plutus.Contracts.FungibleToken where

import           Ledger.Typed.Scripts      (MonetaryPolicy)
import qualified Ledger.Typed.Scripts      as Scripts
import           Plutus.V1.Ledger.Contexts (ScriptContext)
import qualified Plutus.V1.Ledger.Scripts  as Scripts
import           Plutus.V1.Ledger.Value    (TokenName, Value)
import qualified PlutusTx

{-# INLINABLE validator #-}
validator :: TokenName -> ScriptContext -> Bool
validator _ _ = True

makeLiquidityPolicy :: TokenName -> MonetaryPolicy
makeLiquidityPolicy tokenName = Scripts.mkMonetaryPolicyScript $
  $$(PlutusTx.compile [|| Scripts.wrapMonetaryPolicy . validator ||])
    `PlutusTx.applyCode`
        PlutusTx.liftCode tokenName
2

2 Answers 2

3

The pragma {-# LANGUAGE NoImplicitPrelude #-} and import PlutusTx.Prelude might help.

It replaces the implicitly defined functions in Haskell by inlinable alternatives. Here is an example for Boolean operators.

1
  • That could have worked, but I tried and the error is still the same. The validator inside module Plutus.Contracts.FungibleToken did not use any functions from Prelude, so that's expectable. Commented May 18, 2021 at 9:21
3

The way HLS is enabled without plugin errors is discussed here:

Basically, you need to enable defer-plugin-errors flag. You can do this with following command:

cabal configure -f defer-plugin-errors

Remember to turn it off when you actually need to check if validators are compiled properly. This resets configuration:

cabal configure

1
  • It works! Thank you
    – kindofdev
    Commented Feb 9, 2022 at 9:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.