-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CaseOfCase kind mismatch error fix (#5923)
* Fix issue #5922 * test_extractTyArgs * CaseOfCase: cover types with two type args
- Loading branch information
1 parent
5e09318
commit 3f15d43
Showing
6 changed files
with
122 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{-# LANGUAGE BlockArguments #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module PlutusIR.Contexts.Tests where | ||
|
||
import PlutusIR | ||
import PlutusIR.Contexts | ||
|
||
import PlutusCore.Default (DefaultFun, DefaultUni) | ||
import PlutusCore.Name.Unique (Unique (..)) | ||
import Test.Tasty (TestTree, testGroup) | ||
import Test.Tasty.HUnit (testCase, (@?=)) | ||
|
||
test_extractTyArgs :: TestTree | ||
test_extractTyArgs = | ||
testGroup | ||
"Applying extractTyArgs to an" | ||
[ testCase "empty AppContext evaluates to an empty list of ty args" do | ||
extractTyArgs AppContextEnd @?= Just ([] :: [Type TyName DefaultUni ()]) | ||
, testCase "AppContext without type applications evaluates to Nothing" do | ||
extractTyArgs (TermAppContext term () AppContextEnd) @?= Nothing | ||
, testCase "AppContext with a mix of term and type applications evaluates to Nothing" do | ||
extractTyArgs (TypeAppContext ty1 () (TermAppContext term () AppContextEnd)) @?= Nothing | ||
extractTyArgs (TermAppContext term () (TypeAppContext ty1 () AppContextEnd)) @?= Nothing | ||
, testCase "AppContext with type applications only evaluates to Just (list of ty vars)" do | ||
extractTyArgs (TypeAppContext ty1 () (TypeAppContext ty2 () AppContextEnd)) | ||
@?= Just [ty1, ty2] | ||
] | ||
|
||
---------------------------------------------------------------------------------------------------- | ||
-- Test values ------------------------------------------------------------------------------------- | ||
|
||
term :: Term TyName Name DefaultUni DefaultFun () | ||
term = Var () (Name "x" (Unique 0)) | ||
|
||
ty1 :: Type TyName DefaultUni () | ||
ty1 = TyVar () (TyName (Name "t" (Unique 0))) | ||
|
||
ty2 :: Type TyName DefaultUni () | ||
ty2 = TyVar () (TyName (Name "t" (Unique 1))) |
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
30 changes: 30 additions & 0 deletions
30
plutus-core/plutus-ir/test/PlutusIR/Transform/CaseOfCase/twoTyArgs
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,30 @@ | ||
(let | ||
(nonrec) | ||
(datatypebind | ||
(datatype | ||
(tyvardecl d12 (fun (fun (type) (type)) (fun (type) (type)))) | ||
(tyvardecl a3 (fun (type) (type))) (tyvardecl a10 (type)) | ||
m11 | ||
(vardecl c6 (fun (con unit) [ [ d12 a3 ] a10 ])) | ||
) | ||
) | ||
[ | ||
{ | ||
[ | ||
{ { m11 (con list) } (con unit) } | ||
[ | ||
{ | ||
[ | ||
{ { m11 (con list) } (con unit) } | ||
(error [ [ d12 (con list) ] (con unit) ]) | ||
] | ||
[ [ d12 (con list) ] (con unit) ] | ||
} | ||
(lam x23 (con unit) (error [ [ d12 (con list) ] (con unit) ])) | ||
] | ||
] | ||
(con unit) | ||
} | ||
(error (fun (con unit) (con unit))) | ||
] | ||
) |
40 changes: 40 additions & 0 deletions
40
plutus-core/plutus-ir/test/PlutusIR/Transform/CaseOfCase/twoTyArgs.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,40 @@ | ||
(let | ||
(nonrec) | ||
(datatypebind | ||
(datatype | ||
(tyvardecl d12 (fun (fun (type) (type)) (fun (type) (type)))) | ||
(tyvardecl a3 (fun (type) (type))) (tyvardecl a10 (type)) | ||
m11 | ||
(vardecl c6 (fun (con unit) [ [ d12 a3 ] a10 ])) | ||
) | ||
) | ||
(let | ||
(nonrec) | ||
(termbind | ||
(strict) | ||
(vardecl k_caseOfCase (fun [ [ d12 (con list) ] (con unit) ] (con unit))) | ||
(lam | ||
scrutinee | ||
[ [ d12 (con list) ] (con unit) ] | ||
[ | ||
{ [ { { m11 (con list) } (con unit) } scrutinee ] (con unit) } | ||
(error (fun (con unit) (con unit))) | ||
] | ||
) | ||
) | ||
[ | ||
{ | ||
[ | ||
{ { m11 (con list) } (con unit) } | ||
(error [ [ d12 (con list) ] (con unit) ]) | ||
] | ||
(con unit) | ||
} | ||
(lam | ||
x23 | ||
(con unit) | ||
[ k_caseOfCase (error [ [ d12 (con list) ] (con unit) ]) ] | ||
) | ||
] | ||
) | ||
) |