tk3369 / BinaryTraits.jl

Can do or not? It's easy. See https://tk3369.github.io/BinaryTraits.jl/dev/
MIT License
53 stars 3 forks source link

Unable to check interface from outside a module #58

Open tk3369 opened 2 years ago

tk3369 commented 2 years ago

If I define a module and then try to verify interfaces from outside of the module, it gets confused:

julia> module Foo
           using BinaryTraits
           using BinaryTraits.Prefix: Is
           @trait Cute
           @implement Is{Cute} by awesome(_)
           struct Wat end
           @assign Wat with Is{Cute}
       end

julia> @check Foo.Wat
✅ Main.Foo.Wat has no interface contract requirements.

The workaround is to run the check inside the module, or expose a method to do that:

julia> module Bar
           using BinaryTraits
           using BinaryTraits.Prefix: Is
           @trait Cute
           @implement Is{Cute} by awesome(_)
           struct Wat end
           @assign Wat with Is{Cute}
           testme() = @check Wat
       end

julia> Bar.testme()
┌ Warning: Missing implementation
│   contract = BinaryTrait{Main.Bar.Cute}: BinaryTraits.Prefix.Positive{Main.Bar.Cute} ⇢ awesome(🔹)
└ @ BinaryTraits ~/.julia/dev/BinaryTraits/src/interface.jl:62
❌ Main.Bar.Wat is missing these implementations:
1. BinaryTrait{Main.Bar.Cute}: BinaryTraits.Prefix.Positive{Main.Bar.Cute} ⇢ awesome(🔹) (Missing implementation)