-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interface Checking Broken on 1.10.0 #62
Comments
Stopgap solution: if you add type annotations to your julia> @implement Prefix.Is{Foo} by f(_, x::Any)
julia> @check Bar
✅ Bar has implemented:
1. BinaryTrait{Foo}: Positive{Foo} ⇢ f(🔹, ::Any) |
Huge help, @SBuercklin. |
Temporary solution still breaks if you type annotate the implementation: julia> using BinaryTraits
julia> using BinaryTraits: Prefix
julia> @trait Foo
julia> @implement Prefix.Is{Foo} by f(_, x::Any)
julia> struct Bar end
julia> f(::Bar, x::Float64) = 1
f (generic function with 1 method)
julia> @assign Bar with Prefix.Is{Foo}
julia> @check Bar
┌ Warning: Missing implementation
│ contract = BinaryTrait{Foo}: Positive{Foo} ⇢ f(🔹, ::Any)
└ @ BinaryTraits ~/.julia/packages/BinaryTraits/Hl5cc/src/interface.jl:62
❌ Bar is missing these implementations:
1. BinaryTrait{Foo}: Positive{Foo} ⇢ f(🔹, ::Any) (Missing implementation) |
That's an expected failure because the implemented method does not satisfy the interface. |
Maybe I don't fully understand how the package works then - I would expect a subtype to satisfy? What am I missing? Nvm - I had them reversed |
This is the actual MWE which I am struggling with (which works with Julia 1.9): using BinaryTraits
using BinaryTraits: Prefix
@trait Foo
@trait Faz
abstract type AbstractBar end
abstract type AbstractBoo end
struct Bar end
struct Boo end
@implement Prefix.Is{Foo} by f(_, x)
@implement Prefix.Is{Faz} by f(x, _)
f(::Bar, x::Boo) = 1
@assign Bar with Prefix.Is{Foo}
@assign Boo with Prefix.Is{Faz}
@check Bar
@check Boo I don't think you can make the stopgap solution work for this scenario? |
|
Yeah that makes sense, so this passing in Julia <1.9 was a bug really |
No, the interfaces defined by
vs
are distinct. If you need a more strict interface than |
Ok, I suppose the lapse in my understanding then is how exactly BinaryTraits.jl handles |
Sorry for being late to the party :-) I have been too busy at work and not able to spend time on open source lately. I have looked into this issue. It appears that the problem will be fixed by Julia 1.12 according to the latest comment from this issue JuliaLang/julia#52385 Why this was brokenAs a trait package, BinaryTraits provide a way to suers to define interfaces and validate structs against pre-defined interfaces. When an interface contract says that a function must work with This diagram illustrate how it works The primary facility that it checks for implementation is to use julia> f(::Integer) = 1
julia> hasmethod(f, Tuple{Union{}})
ERROR: Tuple field type cannot be Union{} WorkaroundThe stop gap solution suggested above works, but I want to point out that it gives you different semantic. If you replace |
Thanks for checking in :) I'm happy to see #52385 is getting resolved, having a bottom type and being able to make |
MWE
The issue seems to be covered by this issue on the Julia repo. If that problem is resolved such that we can use
Tuple{Union{}}
again, I suspect this will go back to workingThe text was updated successfully, but these errors were encountered: