Skip to content

Commit

Permalink
[ fix ] consider nest when guessing scrutinee
Browse files Browse the repository at this point in the history
  • Loading branch information
dunhamsteve committed Sep 5, 2023
1 parent c52b029 commit 231291e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/TTImp/Elab/Case.idr
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,9 @@ checkCase rig elabinfo nest env fc opts scr scrty_in alts exp
= case getFn x of
IVar _ n =>
do defs <- get Ctxt
[(n', (_, ty))] <- lookupTyName n (gamma defs)
[(n', (_, ty))] <- do nested <- maybe (pure []) (\n => lookupTyName n (gamma defs))
(join $ Builtin.fst <$> List.lookup n nest.names)
(nested ++) <$> lookupTyName n (gamma defs)
| _ => guessScrType xs
Just (tyn, tyty) <- getRetTy defs !(nf defs [] ty)
| _ => guessScrType xs
Expand Down
2 changes: 1 addition & 1 deletion tests/Main.idr
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ idrisTestsBasic = MkTestPool "Fundamental language features" [] Nothing
"idiom001",
"literals001",
"dotted001",
"case001",
"case001", "case002",
"rewrite001",
"interpolation001", "interpolation002", "interpolation003",
"interpolation004"]
Expand Down
11 changes: 11 additions & 0 deletions tests/idris2/case002/WhereData.idr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Main

foo : Int -> Int
foo x = case isLT of
Yes => x*2
No => x*4
where
data MyLT = Yes | No

isLT : MyLT
isLT = if x < 20 then Yes else No
1 change: 1 addition & 0 deletions tests/idris2/case002/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1/1: Building WhereData (WhereData.idr)
3 changes: 3 additions & 0 deletions tests/idris2/case002/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rm -rf build

$1 --no-color --console-width 0 --no-banner --check WhereData.idr

0 comments on commit 231291e

Please sign in to comment.