Skip to content
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

Avoid extending Type from Base on Julia 1.12 #543

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ararslan
Copy link

@ararslan ararslan commented Mar 1, 2025

The internal Flatbuf module defines a function called Type. On Julia 1.12, defining a new function by defining methods is insufficient to distinguish it from defining new constructor methods for a visible type of the same name. It's now necessary to forward-declare the function to ensure it takes precedence over the other visible binding. Without doing so, Base.Type is extended in Flatbuf instead.

On current main with Julia v1.13.0-DEV.122:

julia> using Arrow
Info Given Arrow was explicitly requested, output will be shown live
WARNING: Constructor for type "Type" was extended in `Flatbuf` without explicit qualification or import.
  NOTE: Assumed "Type" refers to `Base.Type`. This behavior is deprecated and may differ in future versions.
  NOTE: This behavior may have differed in Julia versions prior to 1.12.
  Hint: If you intended to create a new generic function of the same name, use `function Type end`.
  Hint: To silence the warning, qualify `Type` as `Base.Type` in the method signature or explicitly `import Base: Type`.
Precompiling Arrow finished.
  1 dependency successfully precompiled in 4 seconds. 47 already precompiled.
  1 dependency had output during precompilation:
┌ Arrow
│  [Output was shown above]
└

julia> methods(Type)
# 2 methods for type constructor:
 [1] Type(b::UInt8)
     @ Arrow.Flatbuf ~/Projects/julia-packages/arrow-julia/src/metadata/Schema.jl:489
 [2] Type(::Type{T}) where T
     @ Arrow.Flatbuf ~/Projects/julia-packages/arrow-julia/src/metadata/Schema.jl:519

julia> Arrow.Flatbuf.Type === Type
[ Warning: Type is defined in Core and is not public in Arrow.Flatbuf
true

With this PR, the output is the same because of JuliaLang/julia#57546 but will have the correct behavior once that issue is fixed.

For some reason, the internal Flatbuf module defines a function called
`Type`. On Julia 1.12, defining a new function by defining methods is
insufficient to distinguish it from defining new constructor methods for
a visible type of the same name. It's now necessary to forward-declare
the function to ensure it takes precedence over the other visible
binding. Without doing so, `Base.Type` is extended in Flatbuf instead.
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.

1 participant