-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ fix ] fix shadowing issue in record elaboration and reflection
- Loading branch information
1 parent
4e8847b
commit 8326932
Showing
7 changed files
with
130 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Data.Vect | ||
record Foo (th : Vect n a) where | ||
nIsZero : n === 0 | ||
vectIsEmpty : (th ===) | ||
$ replace {p = \ n => Vect n a} (sym nIsZero) | ||
$ Nil | ||
|
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 @@ | ||
1/1: Building RecordParam (RecordParam.idr) | ||
1/1: Building Issue3501 (Issue3501.idr) |
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,3 +1,4 @@ | ||
. ../../../testutils.sh | ||
|
||
check RecordParam.idr | ||
check Issue3501.idr |
100 changes: 100 additions & 0 deletions
100
tests/idris2/reflection/reflection033/QuotingShadowed.idr
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,100 @@ | ||
module QuotingShadowed | ||
|
||
import Data.Vect | ||
|
||
import Language.Reflection | ||
|
||
%language ElabReflection | ||
|
||
X : (Nat -> Nat) -> Type | ||
X f = Vect (f 2) Unit | ||
|
||
-------------------------- | ||
--- Shadowing using UN --- | ||
-------------------------- | ||
|
||
-- (x : Nat) -> (y : X (\x -> S x)) -> Nat | ||
tyExpr : TTImp | ||
tyExpr = | ||
IPi EmptyFC MW ExplicitArg (Just `{x}) `(Prelude.Types.Nat) $ | ||
IPi EmptyFC MW ExplicitArg (Just `{y}) ( | ||
IApp EmptyFC `(QuotingShadowed.X) $ | ||
ILam EmptyFC MW ExplicitArg (Just $ UN $ Basic "x") `(Prelude.Types.Nat) $ | ||
IApp EmptyFC `(Prelude.Types.S) $ IVar EmptyFC `{x} | ||
) $ | ||
`(Prelude.Types.Nat) | ||
|
||
ty : Elab Type | ||
ty = check tyExpr | ||
|
||
T : Type | ||
T = %runElab ty | ||
|
||
f : T | ||
f n [(), (), ()] = 4 | ||
|
||
-------------------------------- | ||
--- Pseudo-shadowing with MN --- | ||
-------------------------------- | ||
|
||
tyExpr' : TTImp | ||
tyExpr' = | ||
IPi EmptyFC MW ExplicitArg (Just `{x}) `(Prelude.Types.Nat) $ | ||
IPi EmptyFC MW ExplicitArg (Just `{y}) ( | ||
IApp EmptyFC `(QuotingShadowed.X) $ | ||
ILam EmptyFC MW ExplicitArg (Just $ MN "x" 0) `(Prelude.Types.Nat) $ | ||
IApp EmptyFC `(Prelude.Types.S) $ IVar EmptyFC `{x} | ||
) $ | ||
`(Prelude.Types.Nat) | ||
|
||
ty' : Elab Type | ||
ty' = check tyExpr' | ||
|
||
T' : Type | ||
T' = %runElab ty' | ||
|
||
f' : T' | ||
f' Z [()] = 4 | ||
f' (S x) (()::xs) = S $ f' x xs | ||
|
||
-------------------------------- | ||
--- Requoted the one with UN --- | ||
-------------------------------- | ||
|
||
tyExpr'' : TTImp | ||
tyExpr'' = %runElab quote T | ||
ty'' : Elab Type | ||
ty'' = check tyExpr'' | ||
T'' : Type | ||
T'' = %runElab ty'' | ||
f'' : T'' | ||
f'' n [(), (), ()] = 4 | ||
-- check that T'' has really `MN _ 0` -- | ||
N'' : Nat | ||
N'' = case tyExpr'' of | ||
(IPi _ _ _ _ _ $ IPi _ _ _ _ (IApp _ _ $ ILam _ _ _ (Just n) _ _) _) => | ||
case n of | ||
UN _ => 1 | ||
MN "x" 0 => 2 | ||
_ => 3 | ||
_ => 0 | ||
n''value : N'' = 2 | ||
n''value = Refl | ||
-------------------- | ||
--- Printing out --- | ||
-------------------- | ||
%runElab logSugaredTerm "shdw" 0 "tyExpr " tyExpr | ||
%runElab logSugaredTerm "shdw" 0 "tyExpr' " tyExpr' | ||
%runElab logSugaredTerm "shdw" 0 "tyExpr''" tyExpr'' | ||
%runElab logSugaredTerm "shdw" 0 "quoted T " !(quote T ) | ||
%runElab logSugaredTerm "shdw" 0 "quoted T' " !(quote T' ) | ||
%runElab logSugaredTerm "shdw" 0 "quoted T''" !(quote T'') |
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,7 @@ | ||
1/1: Building QuotingShadowed (QuotingShadowed.idr) | ||
LOG shdw:0: tyExpr : (x : Nat) -> (y : X (\x => S x)) -> Nat | ||
LOG shdw:0: tyExpr' : (x : Nat) -> (y : X (\{x:0} => S x)) -> Nat | ||
LOG shdw:0: tyExpr'': (x : Nat) -> (y : X (\{x:0} => S {x:0})) -> Nat | ||
LOG shdw:0: quoted T : (x : Nat) -> (y : X (\{x:0} => S {x:0})) -> Nat | ||
LOG shdw:0: quoted T' : (x : Nat) -> (y : X (\{x:0} => S x)) -> Nat | ||
LOG shdw:0: quoted T'': (x : Nat) -> (y : X (\{x:0} => S {x:0})) -> Nat |
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,3 @@ | ||
. ../../../testutils.sh | ||
|
||
check --show-machine-names QuotingShadowed.idr |