IntersectMBO / plutus

The Plutus language implementation and tools
Apache License 2.0
1.57k stars 476 forks source link

Compilation fails if `elem` function is used and script and compilation are in different modules #5130

Closed uhbif19 closed 1 year ago

uhbif19 commented 1 year ago

Summary

Compilation fails if elem function is used and script and compilation are in different modules.

Using self-made elem function fails iff it is polymorphic on Eq, but works if it is monomorphic (this works: https://github.com/mlabs-haskell/hydra-auction/pull/69/files)

Steps to reproduce the behavior

  1. Use elem function from PlutuxTx.Prelude in script
  2. Compile script in another module

Actual Result

Error in case of custom polymorphic elem: https://pastebin.com/QjHkdMav Error in case of PlutusTx elem: https://pastebin.com/WY1dWXtX

Expected Result

Compiles without error

Describe the approach you would take to fix this

No response

System info

ArchLinux

plutus-core == 1.0.0.0 plutus-tx-plugin == 1.0.0.0 plutus-ledger-api==1.0.0.0

effectfully commented 1 year ago

Quoting @michaelpj's response on slack:

function: Variable HydraAuction.OnChain.StateToken.$s$fFoldable[]_$cfoldMap No unfolding

the c means it's a specialized binding created by GHC sometimes it doesn't give them unfoldings because it hates us the solution is usually to put -fno-specialise somewhere

@uhbif19 please tell us if you're able to use this suggestion to fix the problem.

uhbif19 commented 1 year ago

@effectfully

Yes, that worked, thank you.

Sorry for issue, I thought I checked on different flags combination from Troubleshooting page, but apparently missed that one.

effectfully commented 1 year ago

@uhbif19 you're welcome and no problem. Glad it helped, do feel free to open more tickets in future.