Skip to content
This repository has been archived by the owner on May 20, 2024. It is now read-only.

cabal build success but haskell-language-server yields error #46

Open
it4rb opened this issue Apr 27, 2022 · 2 comments
Open

cabal build success but haskell-language-server yields error #46

it4rb opened this issue Apr 27, 2022 · 2 comments

Comments

@it4rb
Copy link

it4rb commented Apr 27, 2022

I'm using current latest commit (e930b2f) and 2nd method (Cabal+Nix build)
After getting into development environment with nix-shell command, I can use cabal build to build the project successfully. However haskell-language-server returns error:

2022-04-27 20:14:50.010342 [ThreadId 400] INFO hls:	File:     /project/plutus-test/examples/src/Plutus/Contracts/Game.hs
Hidden:   no
Range:    1:1-2:1
Source:   compile
Severity: DsError
Message:
  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 PlutusTx.Eq.$fEqBuiltinByteString
  [DFunId(nt)]
  No unfolding
  Context: Compiling expr: PlutusTx.Eq.$fEqBuiltinByteString
  Context: Compiling expr: PlutusTx.Eq.==
  @ PlutusTx.Builtins.Internal.BuiltinByteString
  PlutusTx.Eq.$fEqBuiltinByteString
  Context: Compiling expr: PlutusTx.Eq.==
  @ PlutusTx.Builtins.Internal.BuiltinByteString
  PlutusTx.Eq.$fEqBuiltinByteString
  (ds_d14Bp
  `cast` (Plutus.Contracts.Game.N:HashedString[0]
  :: GHC.Types.Coercible
  Plutus.Contracts.Game.HashedString
  PlutusTx.Builtins.Internal.BuiltinByteString))
  Context: Compiling expr: PlutusTx.Eq.==
  @ PlutusTx.Builtins.Internal.BuiltinByteString
  PlutusTx.Eq.$fEqBuiltinByteString
  (ds_d14Bp
  `cast` (Plutus.Contracts.Game.N:HashedString[0]
  :: GHC.Types.Coercible
  Plutus.Contracts.Game.HashedString
  PlutusTx.Builtins.Internal.BuiltinByteString))
  (PlutusTx.Builtins.sha2_256
  (ds_d14Bq
  `cast` (Plutus.Contracts.Game.N:ClearString[0]
  :: GHC.Types.Coercible
  Plutus.Contracts.Game.ClearString
  PlutusTx.Builtins.Internal.BuiltinByteString)))
  Context: Compiling expr: \ (ds_d14Bq [Occ=Once]
  :: Plutus.Contracts.Game.ClearString) ->
  PlutusTx.Eq.==
  @ PlutusTx.Builtins.Internal.BuiltinByteString
  PlutusTx.Eq.$fEqBuiltinByteString
  (ds_d14Bp
  `cast` (Plutus.Contracts.Game.N:HashedString[0]
  :: GHC.Types.Coercible
  Plutus.Contracts.Game.HashedString
  PlutusTx.Builtins.Internal.BuiltinByteString))
  (PlutusTx.Builtins.sha2_256
  (ds_d14Bq
  `cast` (Plutus.Contracts.Game.N:ClearString[0]
  :: GHC.Types.Coercible
  Plutus.Contracts.Game.ClearString
  PlutusTx.Builtins.Internal.BuiltinByteString)))
  Context: Compiling expr: \ (ds_d14Bp [Occ=Once]
  :: Plutus.Contracts.Game.HashedString)
  (ds_d14Bq [Occ=Once] :: Plutus.Contracts.Game.ClearString) ->
  PlutusTx.Eq.==
  @ PlutusTx.Builtins.Internal.BuiltinByteString
  PlutusTx.Eq.$fEqBuiltinByteString
  (ds_d14Bp
  `cast` (Plutus.Contracts.Game.N:HashedString[0]
  :: GHC.Types.Coercible
  Plutus.Contracts.Game.HashedString
  PlutusTx.Builtins.Internal.BuiltinByteString))
  (PlutusTx.Builtins.sha2_256
  (ds_d14Bq
  `cast` (Plutus.Contracts.Game.N:ClearString[0]
  :: GHC.Types.Coercible
  Plutus.Contracts.Game.ClearString
  PlutusTx.Builtins.Internal.BuiltinByteString)))
  Context: Compiling definition of: Plutus.Contracts.Game.isGoodGuess
  Context: Compiling expr: Plutus.Contracts.Game.isGoodGuess
  Context: Compiling expr: Plutus.Contracts.Game.isGoodGuess hs
  Context: Compiling expr: Plutus.Contracts.Game.isGoodGuess hs cs
  Context: Compiling expr: \ _ [Occ=Dead] ->
  Plutus.Contracts.Game.isGoodGuess hs cs
  Context: Compiling expr: \ (cs [Occ=Once]
  :: Plutus.Contracts.Game.ClearString)
  _ [Occ=Dead] ->
  Plutus.Contracts.Game.isGoodGuess hs cs
  Context: Compiling expr: \ (hs [Occ=Once]
  :: Plutus.Contracts.Game.HashedString)
  (cs [Occ=Once] :: Plutus.Contracts.Game.ClearString)
  _ [Occ=Dead] ->
  Plutus.Contracts.Game.isGoodGuess hs cs
  Context: Compiling definition of: Plutus.Contracts.Game.validateGuess
  Context: Compiling expr: Plutus.Contracts.Game.validateGuess
  Context: Compiling expr at "main:Plutus.Contracts.Game:(81,8)-(81,46)"

I've tried to update validateGuess to just return True:

validateGuess :: HashedString -> ClearString -> ScriptContext -> Bool
-- validateGuess hs cs _ = isGoodGuess hs cs
validateGuess _ _ _ = True

and now it yields different error:

2022-04-27 20:25:52.399061 [ThreadId 443] INFO hls:	File:     /project/plutus-test/examples/src/Plutus/Contracts/Game.hs
Hidden:   no
Range:    1:1-2:1
Source:   compile
Severity: DsError
Message:
  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 Ledger.Typed.Scripts.Validators.wrapValidator
  No unfolding
  Context: Compiling expr: Ledger.Typed.Scripts.Validators.wrapValidator
  Context: Compiling expr: Ledger.Typed.Scripts.Validators.wrapValidator
  @ Plutus.Contracts.Game.HashedString
  Context: Compiling expr: Ledger.Typed.Scripts.Validators.wrapValidator
  @ Plutus.Contracts.Game.HashedString
  @ Plutus.Contracts.Game.ClearString
  Context: Compiling expr: Ledger.Typed.Scripts.Validators.wrapValidator
  @ Plutus.Contracts.Game.HashedString
  @ Plutus.Contracts.Game.ClearString
  Plutus.Contracts.Game.$fUnsafeFromDataHashedString
  Context: Compiling expr: Ledger.Typed.Scripts.Validators.wrapValidator
  @ Plutus.Contracts.Game.HashedString
  @ Plutus.Contracts.Game.ClearString
  Plutus.Contracts.Game.$fUnsafeFromDataHashedString
  Plutus.Contracts.Game.$fUnsafeFromDataClearString
  Context: Compiling expr at "main:Plutus.Contracts.Game:(82,8)-(82,37)"

I've also tried adding {-# INLINABLE ... #-} to both gameInstance and validateGuess but still getting the same error.

Is there any additional setup need to be done for HLS to work?

Thank you!

@deanodev
Copy link

deanodev commented Apr 28, 2022

Do you get the same error with current Main or just latest commit?

@it4rb
Copy link
Author

it4rb commented Apr 29, 2022

Do you get the same error with current Main or just latest commit?

The commit I was referring is the latest commit in Main branch

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants