-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SCP-2638: simplify datatypes which are used only at the type-level
1. Change dependency analysis to account for the fact that the term-level parts can be removed (see note). 2. Simplify datatype bindings into trivial type bindings if all their term-level parts are dead. Had to do a bit of test rearrangement since a lot of the `plutus-tx-plugin` tests for a type T just used a lambda with an unused argument of type T... which gets simplified with this PR! Fixes #4147. Fixes #3702.
- Loading branch information
Showing
20 changed files
with
204 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
plutus-core/plutus-ir/test/errors/mutuallyRecursiveTypes.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
E003: Unsupported construct: Mutually recursive datatypes ((recursive) let binding; from mutuallyRecursiveTypes:1:2) | ||
E003: Unsupported construct: Mutually recursive datatypes ((recursive) let binding; from [ mutuallyRecursiveTypes:1:2 | ||
, mutuallyRecursiveTypes:4:2 ]) |
10 changes: 3 additions & 7 deletions
10
plutus-core/plutus-ir/test/transform/deadCode/datatypeLiveType.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
(let | ||
(nonrec) | ||
(datatypebind | ||
(datatype | ||
(tyvardecl Maybe (fun (type) (type))) | ||
(tyvardecl a (type)) | ||
match_Maybe | ||
(vardecl Nothing [ Maybe a ]) (vardecl Just (fun a [ Maybe a ])) | ||
) | ||
(typebind | ||
(tyvardecl Maybe (fun (type) (type))) | ||
(lam a (type) (all a (type) (fun a a))) | ||
) | ||
(error Maybe) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,6 @@ | |
(vardecl Constr (fun unit SomeType)) | ||
) | ||
) | ||
(lam arg SomeType arg) | ||
[Constr (error unit)] | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,6 @@ | |
(vardecl Constr (fun unit SomeType)) | ||
) | ||
) | ||
(lam arg SomeType arg) | ||
[ Constr (error unit) ] | ||
) | ||
) |
16 changes: 16 additions & 0 deletions
16
plutus-core/plutus-ir/test/transform/deadCode/pruneDatatype
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
(let | ||
(nonrec) | ||
(typebind (tyvardecl unit (type)) (all a (type) (fun a a))) | ||
(let | ||
(nonrec) | ||
(datatypebind | ||
(datatype | ||
(tyvardecl SomeType (type)) | ||
|
||
match_SomeType | ||
(vardecl Constr (fun unit SomeType)) | ||
) | ||
) | ||
(lam arg SomeType (error unit)) | ||
) | ||
) |
9 changes: 9 additions & 0 deletions
9
plutus-core/plutus-ir/test/transform/deadCode/pruneDatatype.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
(let | ||
(nonrec) | ||
(typebind (tyvardecl unit (type)) (all a (type) (fun a a))) | ||
(let | ||
(nonrec) | ||
(typebind (tyvardecl SomeType (type)) (all a (type) (fun a a))) | ||
(lam arg SomeType (error unit)) | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
plutus-core/plutus-ir/test/transform/retainedSize/nestedBindingsIndirect.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.