Skip to content

Commit

Permalink
ignore normalization of cases
Browse files Browse the repository at this point in the history
  • Loading branch information
janmasrovira committed Jun 7, 2024
1 parent a2c1a4a commit 50b5dc4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ queryMetavarFinal h = do
Just (ExpressionHole h') -> queryMetavarFinal h'
_ -> return m

-- FIXME the returned expression should have the same location as the original
strongNormalize' :: forall r. (Members '[ResultBuilder, State InferenceState, NameIdGen] r) => Expression -> Sem r Expression
strongNormalize' = go
where
Expand All @@ -149,7 +150,7 @@ strongNormalize' = go
-- We just recurse inside
ExpressionLet l -> ExpressionLet <$> goLet l
-- TODO it should normalize like an applied lambda
ExpressionCase {} -> error "normalization of case expressions is not supported yet"
ExpressionCase c -> return (ExpressionCase c)

goLet :: Let -> Sem r Let
goLet Let {..} = do
Expand Down
7 changes: 7 additions & 0 deletions test/Typecheck/Negative.hs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,13 @@ tests =
$(mkRelFile "LoopingCoercion.juvix")
$ \case
ErrCoercionCycles {} -> Nothing
_ -> wrongError,
negTest
"Wrong type (issue 2771)"
$(mkRelDir "issue2771")
$(mkRelFile "Main.juvix")
$ \case
ErrWrongType {} -> Nothing
_ -> wrongError
]

Expand Down
12 changes: 12 additions & 0 deletions tests/positive/issue2771/Main.juvix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Main;

type T := t;

type Box := mkBox { unbox : T };

f (b : Box) : Box :=
case b of {
mkBox _ := mkBox t
};

main : T := f (mkBox t);
5 changes: 5 additions & 0 deletions tests/positive/issue2771/Package.juvix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Package;

import PackageDescription.V2 open;

package : Package := defaultPackage {name := "issue2771"};

0 comments on commit 50b5dc4

Please sign in to comment.