Skip to content

Commit

Permalink
fix: Ensure that pattern matching an animation only produces a wildcard
Browse files Browse the repository at this point in the history
Previously, it was possible for example to take an expression `match (? : Maybe Animation) with {Nothing -> ? ; Just x -> ?}`, then, by raising `Animation`, create `match (? : Animation) with {Nothing -> ? ; Just -> ? ; _ -> ?}`. Now we ensure that those first two nonsensical branches are removed.

Signed-off-by: George Thomas <[email protected]>
  • Loading branch information
georgefst committed Nov 21, 2023
1 parent 56cbac5 commit ce07999
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion primer/src/Primer/Typecheck.hs
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ check t = \case
PatPrim (PrimChar p) -> pure p
_ -> Nothing
-- some primitives do not admit any sensible notion of pattern matching
| tc == tAnimation -> pure True
| tc == tAnimation -> pure $ null brs
| otherwise -> throwError' $ InternalError $ "Unknown primitive type: " <> show tc
brs' <-
if consistentBranches
Expand Down

0 comments on commit ce07999

Please sign in to comment.