Skip to content

Commit

Permalink
Merge pull request #3306 from dunhamsteve/implicitParam
Browse files Browse the repository at this point in the history
[ fix ] implicits are not in scope under an implicit parameter block
  • Loading branch information
andrevidela authored Jun 17, 2024
2 parents 0c03002 + f9d00ea commit ddb691b
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/TTImp/TTImp.idr
Original file line number Diff line number Diff line change
Expand Up @@ -726,9 +726,10 @@ implicitsAs n defs ns tm
Core (List (Name, PiInfo RawImp))
-- #834 When we are in a local definition, we have an explicit telescope
-- corresponding to the variables bound in the parent function.
-- So we first peel off all of the explicit quantifiers corresponding
-- to these variables.
findImps ns es (_ :: locals) (NBind fc x (Pi _ _ Explicit _) sc)
-- Parameter blocks also introduce additional telescope of implicit, auto,
-- and explicit variables. So we first peel off all of the quantifiers
-- corresponding to these variables.
findImps ns es (_ :: locals) (NBind fc x (Pi _ _ _ _) sc)
= do body <- sc defs (toClosure defaultOpts [] (Erased fc Placeholder))
findImps ns es locals body
-- ^ TODO? check that name of the pi matches name of local?
Expand Down
7 changes: 7 additions & 0 deletions tests/idris2/reg/reg053/ImplicitParam.idr
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Data.Vect

-- m was not in scope when n is implicit
parameters {n : Nat}
foo : Vect m Nat -> Nat
foo xs = ?hole

4 changes: 4 additions & 0 deletions tests/idris2/reg/reg053/Issue2444.idr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters {0 res : Type}
fun : {x : Nat} -> Nat
fun = x

8 changes: 8 additions & 0 deletions tests/idris2/reg/reg053/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
1/1: Building ImplicitParam (ImplicitParam.idr)
Main> {n : Nat}
0 m : Nat
xs : Vect m Nat
------------------------------
hole : Nat
Main> Bye for now!
1/1: Building Issue2444 (Issue2444.idr)
2 changes: 2 additions & 0 deletions tests/idris2/reg/reg053/input
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:ti hole
:q
3 changes: 3 additions & 0 deletions tests/idris2/reg/reg053/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
. ../../../testutils.sh
idris2 ImplicitParam.idr < input
check Issue2444.idr

0 comments on commit ddb691b

Please sign in to comment.