(I’m using Makie as an example but I think my question is how Julia handle Modules and export
.)
When I run the following code in a REPL session, I get
WARNING: using GeometryBasics.Mesh in module Main conflicts with an existing identifier.
using GLMakie
f = Figure()
a = Axis(f[1, 1])
using GeometryBasics
My questions are
- Why do I get the warning?
- What exactly does it mean?
- How do I debug / test / investigate when I get the warning?
What I have done so far
If I comment out Axis()
, I don’t get that warning.
using GLMakie
f = Figure()
#a = Axis(f[1, 1])
using GeometryBasics
It seems to me both Makie and GeometryBasics exports Mesh
:
:Mesh in names(Makie) #-> true
:Mesh in names(GLMakie) #-> true
:Mesh in names(GeometryBasics) #-> true
But the module Main doesn’t have it:
julia> names(Main)
7-element Vector{Symbol}:
:Base
:Core
:InteractiveUtils
:Main
:a
:ans
:f
When I use ?
, REPL seems to know the identifier Mesh
but throw UndefRefError
help?> Mesh
search: Mesh mesh mesh! MeshMeta MeshScatter meshscatter meshscatter! UVMesh uv_mesh GLUVMesh GLUVMesh3D GLUVMesh2D PlainMesh GLPlainMesh GLPlainMesh3D GLPlainMesh2D TriangleMesh AbstractMesh
ERROR: UndefRefError: access to undefined reference
Stacktrace:
[1] getproperty
@ ./Base.jl:37 [inlined]
[2] summarize(io::IOBuffer, TT::Type, binding::Base.Docs.Binding)
@ REPL ~/julia-1.7.2/share/julia/stdlib/v1.7/REPL/src/docview.jl:286
[3] summarize(binding::Base.Docs.Binding, sig::Type)
@ REPL ~/julia-1.7.2/share/julia/stdlib/v1.7/REPL/src/docview.jl:249
[4] doc(binding::Base.Docs.Binding, sig::Type)
@ REPL ~/julia-1.7.2/share/julia/stdlib/v1.7/REPL/src/docview.jl:182
[5] doc(binding::Base.Docs.Binding)
@ REPL ~/julia-1.7.2/share/julia/stdlib/v1.7/REPL/src/docview.jl:160
[6] top-level scope
@ ~/julia-1.7.2/share/julia/stdlib/v1.7/REPL/src/docview.jl:470
julia>
Searched here in this forum
Some one suggest that importing the same file twice cause this warning, but I can’t reproduce with:
julia> import GeometryBasics: Mesh
julia> import GeometryBasics: Mesh
julia>
I can’t do import MakieCore: Mesh
, can I?
Searched source code but…
src/Makie.jl
has
using MakieCore: Heatmap, [...], Mesh, [...]
export Heatmap, [...], Mesh, [...]
MakieCore/src/basic_plots.jl
has a macro with Mesh
but I’m not sure exactly what it does
@recipe(Mesh, mesh) do scene
Attributes(;
default_theme(scene)...,
color = :black,
backlight = 0f0,
colormap = theme(scene, :colormap),
colorrange = automatic,
interpolate = true,
shading = true,
fxaa = true,
inspectable = theme(scene, :inspectable),
cycle = [:color => :patchcolor],
space = :data
)
end