LanguageServer.jl icon indicating copy to clipboard operation
LanguageServer.jl copied to clipboard

Submodules can't find types from Main module

Open zot opened this issue 3 years ago • 2 comments

For a main program project, VSCode and Emacs show type information for the Person struct in included.jl but not in submodule.jl.

When the project itself is a module, things seem to work properly.

Here's the test case that breaks it:

lstest.zip

LsTest.jl:

struct Person
    name::AbstractString
    address::AbstractString
end

include("submodule.jl")
include("included.jl")

submodule.jl:

module Submodule

import ..Main: Person

println(Person)
println(Main.Person)

end

included.jl:

println(Person)

The test case that works is almost the same, except it uses the project module instead of Main...

lstest2.zip

LsTest2:

module LsTest2

struct Person
    name::AbstractString
    address::AbstractString
end

include("submodule.jl")
include("included.jl")

end # module

submodule.jl:

module Submodule

import ..LsTest2: Person

println(Person)
println(Main.Person)

end

included.jl:

println(Person)

zot avatar Jan 31 '22 18:01 zot

FWIW, import ..Person works fine in both cases :)

pfitzseb avatar Feb 01 '22 11:02 pfitzseb

OK, that's a decent workaround in the interim...

zot avatar Feb 01 '22 11:02 zot