plutus
plutus copied to clipboard
[Test] [Bug] Trigger the overpruned dependency bug
The added test fails with
test
Plugin
Data
9.6
families
stakingCredential: FAIL
Exception: Error: Error from the PIR compiler:
Error from the PLC compiler:
Free type variable at Ann {annInline = MayInline, annSrcSpans = { no-src-span }} : Credential
The bug is in the dead code eliminator. To be precise, it's this part that it doesn't handle correctly despite promising to in PlutusIR.Analysis.Dependencies:
{- Note [Dependencies for datatype bindings, and pruning them]
At face value, all the names introduced by datatype bindings should depend on each other.
Given our meaning of "A depends on B", since we cannot remove any part of the datatype
binding without removing the whole thing, they all depend on each other
However, there are some circumstances in which we *can* prune datatype bindings.
In particular, if the datatype is only used at the type-level (i.e. all the term-level parts
(constructors and destructor) are dead), then we are free to completely replace the binding
with one for a trivial type with the same kind.
This is because there are *no* term-level effects, and types are erased in the end, so
in this case rest of the datatype binding really is superfluous.
But how do we represent this in the dependency graph? We still need to have proper dependencies
so that we don't make the wrong decisions wrt transitively used values, e.g.
let U :: * = ...
let datatype T = T1 | T2 U
in T1
Here we need to not delete U, even though T2 is "dead"!
The solution is to focus on the meaning of "dependency": with the pruning that we can do, we *can*
remove all the term level bits en masse, but only en-mass. So we need to make *them* into a clique,
so that this is visible to the dependency analysis.
-}
I don't know what went wrong there.