Skip to content

Commit

Permalink
feat: Wrap up exhaustive pattern check
Browse files Browse the repository at this point in the history
  • Loading branch information
aboeglin committed Nov 7, 2022
1 parent 092bbe8 commit 2ad436b
Show file tree
Hide file tree
Showing 18 changed files with 315 additions and 186 deletions.
6 changes: 6 additions & 0 deletions .snapshots/should_allow_deconstruction_of_lists/golden
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@
, apath = Just "Module.mad"
}
, [ CompilationWarning
(IncompletePattern [ "[]" ])
Context
{ ctxAstPath = "Module.mad"
, ctxArea = Area (Loc 4 1 5) (Loc 56 3 2)
}
, CompilationWarning
(UnusedTopLevelDeclaration "x")
Context
{ ctxAstPath = "Module.mad"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,12 @@
, apath = Just "Module.mad"
}
, [ CompilationWarning
(IncompletePattern [ "Nothing" ])
Context
{ ctxAstPath = "Module.mad"
, ctxArea = Area (Loc 48 4 3) (Loc 79 6 4)
}
, CompilationWarning
(UnusedConstructor "Nothing")
Context
{ ctxAstPath = "Module.mad"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@
, apath = Just "Module.mad"
}
, [ CompilationWarning
RedundantPattern
Context
{ ctxAstPath = "Module.mad"
, ctxArea = Area (Loc 42 3 3) (Loc 50 3 11)
}
, CompilationWarning
(UnusedTopLevelDeclaration "fn2")
Context
{ ctxAstPath = "Module.mad"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1828,7 +1828,13 @@
]
, apath = Just "Module.mad"
}
, []
, [ CompilationWarning
RedundantPattern
Context
{ ctxAstPath = "Module.mad"
, ctxArea = Area (Loc 125 7 5) (Loc 144 7 24)
}
]
, [ CompilationError
(UnboundVariable "Integer")
Context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@
, ainstances = []
, apath = Just "Module.mad"
}
, []
, [ CompilationWarning
RedundantPattern
Context
{ ctxAstPath = "Module.mad"
, ctxArea = Area (Loc 45 3 3) (Loc 64 3 22)
}
]
, [ CompilationError
(UnboundVariable "Integer")
Context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@
, apath = Just "Module.mad"
}
, [ CompilationWarning
(IncompletePattern [ "[]" ])
Context
{ ctxAstPath = "Module.mad"
, ctxArea = Area (Loc 4 1 5) (Loc 63 4 2)
}
, CompilationWarning
(UnusedTopLevelDeclaration "x")
Context
{ ctxAstPath = "Module.mad"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8706,6 +8706,36 @@
, apath = Just "Module.mad"
}
, [ CompilationWarning
RedundantPattern
Context
{ ctxAstPath = "Module.mad"
, ctxArea = Area (Loc 867 37 5) (Loc 900 37 38)
}
, CompilationWarning
RedundantPattern
Context
{ ctxAstPath = "Module.mad"
, ctxArea = Area (Loc 930 38 5) (Loc 967 38 42)
}
, CompilationWarning
RedundantPattern
Context
{ ctxAstPath = "Module.mad"
, ctxArea = Area (Loc 997 39 5) (Loc 1031 39 39)
}
, CompilationWarning
(IncompletePattern
[ "#[{ ik: _ }, { ik: _ }]"
, "#[{ lui: _ }, { lui: _ }]"
, "#[{ name: _ }, { name: _ }]"
, "#[{ po: { pi: { nameD: _ } } }]"
, "#[{ tchouk: _ }, { tchouk: _ }]"
])
Context
{ ctxAstPath = "Module.mad"
, ctxArea = Area (Loc 781 35 20) (Loc 1206 42 4)
}
, CompilationWarning
(UnusedTopLevelDeclaration "generateFunctionLinks")
Context
{ ctxAstPath = "Module.mad"
Expand Down
6 changes: 6 additions & 0 deletions .snapshots/should_resolve_basic_patterns_for_lists/golden
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,12 @@
, apath = Just "Module.mad"
}
, [ CompilationWarning
(IncompletePattern [ "[]" ])
Context
{ ctxAstPath = "Module.mad"
, ctxArea = Area (Loc 4 1 5) (Loc 103 6 2)
}
, CompilationWarning
(UnusedTopLevelDeclaration "a")
Context
{ ctxAstPath = "Module.mad"
Expand Down
6 changes: 6 additions & 0 deletions .snapshots/should_resolve_where_with_a_Integer_input/golden
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@
, apath = Just "Module.mad"
}
, [ CompilationWarning
(IncompletePattern [ "_" ])
Context
{ ctxAstPath = "Module.mad"
, ctxArea = Area (Loc 4 1 5) (Loc 75 6 2)
}
, CompilationWarning
(UnusedTopLevelDeclaration "x")
Context
{ ctxAstPath = "Module.mad"
Expand Down
6 changes: 6 additions & 0 deletions .snapshots/should_resolve_where_with_a_string_input/golden
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@
, apath = Just "Module.mad"
}
, [ CompilationWarning
(IncompletePattern [ "_" ])
Context
{ ctxAstPath = "Module.mad"
, ctxArea = Area (Loc 4 1 5) (Loc 67 6 2)
}
, CompilationWarning
(UnusedTopLevelDeclaration "x")
Context
{ ctxAstPath = "Module.mad"
Expand Down
9 changes: 8 additions & 1 deletion compiler/main/Driver/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,14 @@ rules options (Rock.Writer (Rock.Writer query)) = case query of

ForeignTypeDeclaration modulePath name -> nonInput $ do
(Slv.AST { Slv.atypedecls }, _) <- Rock.fetch $ SolvedASTWithEnv modulePath
return (List.find (\fullTd@(Slv.Untyped _ td) -> Slv.isADT fullTd && Slv.adtname td == name || Slv.isAlias fullTd && Slv.aliasname td == name) atypedecls, (mempty, mempty))
return ( List.find
(\fullTd@(Slv.Untyped _ td) ->
Slv.isADT fullTd && Slv.adtname td == name
|| Slv.isAlias fullTd && Slv.aliasname td == name
)
atypedecls
, (mempty, mempty)
)

CoreAST path -> nonInput $ do
(slvAst, _) <- Rock.fetch $ SolvedASTWithEnv path
Expand Down
Loading

0 comments on commit 2ad436b

Please sign in to comment.