Skip to content

stop pirating size(::Type{Union{}}) #1306

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

Merged
merged 1 commit into from
May 12, 2025

Conversation

simeonschaub
Copy link
Contributor

JET complained about this method when analyzing my package and it's a
fairly easy fix

JET complained about this method when analyzing my package and it's a
fairly easy fix
@nsajko
Copy link
Contributor

nsajko commented May 11, 2025

How about a test, for example this one:

function test_we_do_not_own_the_call(func, arg_types)
    function f(method)
        StaticArrays != parentmodule(method)
    end
    @test all(f, methods(func, arg_types))
end
 
@testset "type piracy" begin
    @testset "PR #1306: type piracy of `size`" begin
        test_we_do_not_own_the_call(size, Tuple{Type{Union{}}})
    end
end

@simeonschaub
Copy link
Contributor Author

That's a good idea! Unfortunately there is still

size(::Type{SA}) where {SA <: StaticArrayLike} = Tuple(Size(SA))
which isn't that easy to fix. Arguably, length and size should not really be defined on types at all, but that is another discussion.

Copy link
Collaborator

@mateuszbaran mateuszbaran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@mateuszbaran mateuszbaran merged commit 15a2672 into JuliaArrays:master May 12, 2025
17 of 24 checks passed
@mateuszbaran
Copy link
Collaborator

StaticArrayLike is just a union, so fixing it would also be doable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants