Rust codegen Phantom handling bug
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start at lambda-buffers-codegen/src/LambdaBuffers/Codegen/Rust/Print/TyDef.hs around line 177 and inspect how the shown LambdaBuffers definitions become Rust structs. Compare the generated CreateScriptsRequest and ScriptDatum output, checking both the unnecessary phantom_A field and visibility of phantom values. Done means the generated Rust representation matches the source type definitions and handles genuine phantom types correctly.
Written by the indexing model from the issue text.
Description
Phantom handling in Rust codegen is not correct I believe https://github.com/mlabs-haskell/lambda-buffers/blob/401f8a920a557c71440795174da199a1e128c4f9/lambda-buffers-codegen/src/LambdaBuffers/Codegen/Rust/Print/TyDef.hs#L177
record CreateScriptsRequest a = {
scripts : Map ScriptHash (ScriptDatum a)
}
derive Eq (CreateScriptsRequest a)
derive Json (CreateScriptsRequest a)
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)
creates a
#[derive(std::fmt::Debug, std::clone::Clone)]
pub struct CreateScriptsRequest<A>{pub scripts: lbf_prelude::prelude::Map<lbf_plutus::plutus::v1::ScriptHash
,crate::cardano::extra::scriptstorage::validation::ScriptDatum<A>>,
phantom_A: std::marker::PhantomData<A>}
#[derive(std::fmt::Debug, std::clone::Clone)]
pub struct ScriptDatum<A>{pub script_type: A,
pub redeemer: lbf_plutus::plutus::v1::AssetClass}
There's 2 problems here.
- There's no actual phantom types in the original LB type def
- Even if there was, we have a problem when phantom values are not made pub in Rust
- Dominant language
- Haskell
- Stars
- 32
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mlabs-haskell/lambda-buffers
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
mlabs-haskell/lambda-buffers#296 ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
mlabs-haskell/lambda-buffers#295 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 20/100
mlabs-haskell/lambda-buffers#294 ·
-
Dykstra HF Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
mlabs-haskell/lambda-buffers#293 ·
-
Nix-free path Opendevops
Difficulty 5/5 Over a week Newbie friendliness 25/100
mlabs-haskell/lambda-buffers#292 ·
All issues in mlabs-haskell/lambda-buffers
Similar issues
-
docs
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
needs triage type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
doclayout-0.6 Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
commercialhaskell/stackage#8126 ·