Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Plutarch: Using `s` type variable conflicts with the Plutarch scope `s` variable printed by default

Open
#231 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
haskell
Domain
compilers

Research direction

Reproduce the issue with the ScriptDatum example and inspect the generator responsible for autogen/LambdaBuffers/Cardano/Extra/ScriptStorage/Validation/Plutarch.hs. Trace how the source type variable and Plutarch scope variable are named; done means generated Haskell uses distinct binders and compiles without the conflicting-definitions error.

Written by the indexing model from the issue text.

Description

bug codegen plutarch

Sample

record ScriptDatum s = {
  scriptType : s,
  -- ^ Protocol specific script type stored in this UTxO
  redeemer : AssetClass
  -- ^ Wallet containing `$redeemer` must sign the 'delete-script' transaction as an authorization method
}
derive Eq (ScriptDatum s)
derive PlutusData (ScriptDatum s)
derive Json (ScriptDatum s)

Error

       > [1 of 2] Compiling LambdaBuffers.Cardano.Extra.OneShot.Validation.Plutarch ( autogen/LambdaBuffers/Cardano/Extra/OneShot/Validation/Plutarch.hs, dist/build/LambdaBuffers/Cardano/Extra/OneShot/Validation/Plutarch.o, dist/build/LambdaBuffers/Cardano/Extra/OneShot/Validation/Plutarch.dyn_o )
       > [2 of 2] Compiling LambdaBuffers.Cardano.Extra.ScriptStorage.Validation.Plutarch ( autogen/LambdaBuffers/Cardano/Extra/ScriptStorage/Validation/Plutarch.hs, dist/build/LambdaBuffers/Cardano/Extra/ScriptStorage/Validation/Plutarch.o, dist/build/LambdaBuffers/Cardano/Extra/ScriptStorage/Validation/Plutarch.dyn_o )
       >
       > autogen/LambdaBuffers/Cardano/Extra/ScriptStorage/Validation/Plutarch.hs:31:18: error:
       >     Conflicting definitions for ‘s’
       >     Bound at: autogen/LambdaBuffers/Cardano/Extra/ScriptStorage/Validation/Plutarch.hs:31:18-38
       >               autogen/LambdaBuffers/Cardano/Extra/ScriptStorage/Validation/Plutarch.hs:31:40-56
       >    |
       > 31 | data ScriptDatum (s :: Plutarch.PType) (s :: Plutarch.S) = ScriptDatum (Plutarch.Term s (Plutarch.Builtin.PAsData s))
       >    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Workaround

Just use a different letter than s


record ScriptDatum a = {
  scriptType : a,
  -- ^ Protocol specific script type stored in this UTxO
  redeemer : AssetClass
  -- ^ Wallet containing `$redeemer` must sign the 'delete-script' transaction as an authorization method
}
derive Eq (ScriptDatum a)
derive PlutusData (ScriptDatum a)
derive Json (ScriptDatum a)
Dominant language
Haskell
Stars
32
Forks
1
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mlabs-haskell/lambda-buffers

All issues in mlabs-haskell/lambda-buffers

Similar issues

More Haskell issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.