Closed Janiczek closed 3 years ago
This was a confusing one! I tried it out, and you're right that this code works and should not be reported.
I have created failing test cases for this one, should anyone feel like taking this one https://github.com/jfmengels/elm-review-unused/tree/failing-tests-for-issue-5
I noticed that this false positive becomes a true positive when you change A.Foo to type alias Foo = { name : Int }
as that declaration adds a function to the scope, which overrides the import. I have added a test case for that one in the branch so that we don't introduce this problem :slightly_smiling_face:
Describe the bug When a module defines a type alias for a custom type (of the same name, from different module), the constructors of the custom type used in the module aren't taken into consideration in the
NoUnused.CustomTypeConstructors
rule.SSCCE (Short Self-Contained Correct Example) Steps to reproduce the behavior:
import B exposing (Foo(..))
type alias Foo = B.Foo -- this "shadowing" is causing the bug, removing the alias removes the false positive
x = Foo 1 -- usage of the custom type constructor!
elm-review
rules containNoUnused.CustomTypeConstructors.rule []
elm-review
Expected behavior I'd expect not to see warning about the
B.Foo
constructor being unused, because I'm using it inA.x
.