You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
module Main exposing (main)
type Foo = Foo | Bar
id : Foo -> Foo
id f =
case f of
Foo -> Foo
Bar -> Bar
main =
id Foo
There is no path from main that can ever lead to using Bar: the only function that can "create" a Bar is id, but in order to do so, you'd need access to a Bar to begin with. Note that in this instance, it is very clear, but there might be multiple levels of indirection! Essentially, usage of a constructor can be "ignored" in the entire callgraph stemming from matching on that same constructor.
I originally added such functionality to elm-xref after noticing that we had a few such instances in our codebase at work. For reference, implementation happened here: zwilias/elm-xref@7cc14f2 (which might provide some ideas on how to track this sort of thing)
The text was updated successfully, but these errors were encountered:
This issue is fixed on master.
Custom type constructors that require themselves to be built are reported, regardless how deep the pattern they're found in is. I've shown an example here: https://twitter.com/jfmengels/status/1337803716737560577
I have also partially applied the other suggestion. I made it so that "static" comparisons like a == Just Constructor don't count, but "dynamic" comparisons like a == someFunction Constructor would ignore a constructor in the expression, because that expression will always be the same value (True or False) for the entire life of the program. I've shown an example here: https://twitter.com/jfmengels/status/1337910280953716738
I haven't figured yet how to handle the case where we can ignore an if branch based on the condition. I've created #17 to talk about it.
For example, given code like this:
There is no path from
main
that can ever lead to usingBar
: the only function that can "create" aBar
isid
, but in order to do so, you'd need access to aBar
to begin with. Note that in this instance, it is very clear, but there might be multiple levels of indirection! Essentially, usage of a constructor can be "ignored" in the entire callgraph stemming from matching on that same constructor.I originally added such functionality to
elm-xref
after noticing that we had a few such instances in our codebase at work. For reference, implementation happened here: zwilias/elm-xref@7cc14f2 (which might provide some ideas on how to track this sort of thing)The text was updated successfully, but these errors were encountered: