Skip to content

Commit

Permalink
Fix bug in reifies
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximilianAlgehed committed May 6, 2024
1 parent 572b6fd commit 27955a3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion libs/constrained-generators/src/Constrained/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,8 @@ computeSpecSimplified x p = fromGESpec $ case p of
| otherwise -> genError ["Value does not reify to literal: " ++ show val ++ " -/> " ++ show a]
Reifies t' (Lit val) f ->
propagateSpec (equalSpec (f val)) <$> toCtx x t'
Reifies Lit {} _ _ -> pure TrueSpec
Reifies Lit {} _ _ ->
fatalError ["Dependency error in computeSpec: Reifies", " " ++ show p]
-- Impossible cases that should be ruled out by the dependency analysis and linearizer
DependsOn {} ->
fatalError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ forAll' xs f = forAll xs $ \x -> match @fn @p x f

-- | Like `constrained` but pattern matches on the bound `Term fn a`
constrained' ::
forall fn a p.
forall a fn p.
( Cases (SimpleRep a) ~ '[SimpleRep a]
, TypeSpec fn a ~ TypeSpec fn (SimpleRep a)
, HasSpec fn (SimpleRep a)
Expand Down
6 changes: 6 additions & 0 deletions libs/constrained-generators/test/Constrained/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ tests =
prop "Map Int Int" $ prop_conformEmpty @BaseFn @(Map Int Int)
prop "[Int]" $ prop_conformEmpty @BaseFn @[Int]
prop "[(Int, Int)]" $ prop_conformEmpty @BaseFn @[(Int, Int)]
negativeTests

negativeTests :: Spec
negativeTests =
describe "negative tests" $ do
prop "reifies 10 x id" $ expectFailure $ prop_complete @BaseFn @Int $ constrained $ \x -> reifies 10 x id

numberyTests :: Spec
numberyTests =
Expand Down

0 comments on commit 27955a3

Please sign in to comment.