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

`include` several files and missing variable warings

Open gdkrmr opened this issue 7 years ago • 8 comments

I am using emacs with lsp-julia which uses the LanguageServer#master, StaticLint#master, and CSTParser#master and julia 1.0.

When in a project where several files are used with include, LanguageServer often complains about missing variables when these are defined in other files.

gdkrmr avatar Oct 14 '18 15:10 gdkrmr

I won't be able to tell why this is happening or fix it without a replicable example

ZacLN avatar Oct 18 '18 06:10 ZacLN

MyPkg
|- MyPkg.jl
|- a.jl
|- b.jl

MyPkg.jl:

module MyPkg
include("a.jl")
include("b.jl")
end

a.jl:

f(x) = x^2

b.jl:

f2(x) = x * f(x)

then in b.jl LanguageServer.jl thinks that f is a "missing variable".

I could not update to the very latest master because of #295.

gdkrmr avatar Oct 18 '18 06:10 gdkrmr

Fixed on master

ZacLN avatar Nov 13 '18 18:11 ZacLN

Still not working for me on latest master. I initialized the language server like this:

LanguageServerInstance(stdin, stdout, false, "/path/to/package", "", Dict())

gdkrmr avatar Nov 17 '18 21:11 gdkrmr

@ZacLN do we want to fix this for the next release, or move to the backlog?

davidanthoff avatar Dec 29 '18 17:12 davidanthoff

Non blocking for vscode so I'll shift it

ZacLN avatar Dec 30 '18 00:12 ZacLN

Not clear if this is still an issue, moving to backlog for now

ZacLN avatar Jun 16 '19 20:06 ZacLN

Still a big problem on latest version.

Neither hyperlink is working, nor language server is working.

I tried it in neovim (with coc-julia) and atom (with juno) got some weird messages:

OS

linux 5.12.13-arch1-2
julia version 1.6.1

IDE's

neovim

NVIM v0.4.4
node version: v16.4.2
coc.nvim version: 0.0.80-5cd38e9462

atom

atom 1.57.0
Atom.jl 0.12.32

Examples

Example 1) Language server warnings

This is working without any problems.

# a.jl

include("b.jl")
include("c.jl")

function get_function_in_a()
    nice_variable_in_a = 123
    nice_variable_in_a
end

get_function_in_a()

This is also working without any problems.

# b.jl

function get_function_in_b()
    nice_variable_in_b = 123
    nice_variable_in_b
end

get_function_in_b()

This is throwing a language server warning: Variable has been assigned but not used.

# c.jl

function get_function_in_c()
    nice_variable_in_c = 123
    nice_variable_in_c
end

get_function_in_c()

Example 2) Language Server struct

File a.jl and b.jl is the same as above. And after that, I get the warning Cannot declare constant; it already has a value..

# c.jl

mutable struct SomeAwesomeStruct
    field_1
    field_2
    
    method_1
    method_2
    
    function SomeAwesomeStruct()
        this = new()
        
        this.field_1 = "a"
        this.field_2 = "b"
        
        this.method_1 = function()
            # Some awesome code
        end
        this.method_d = function()
            # Also some awesome code
        end
        
        this
    end
end

Example 3) Hyperlink in Atom with JUNO (all plugins)

Hyperlink is working, yay! :)

# a.jl

using SomeAwesomeLibrary

include("b.jl")
include("c.jl")

# some epic code blabla

Hyperlink is working, yay! :)

# b.jl

using SomeAwesomeLibrary

# some epic code blabla

Hyperlink is broken. :(

# c.jl

using SomeAwesomeLibrary

# some epic code blabla

kerkmann avatar Jul 14 '21 09:07 kerkmann