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

@enum with values supplied fails

Open kanubacode opened this issue 3 years ago • 3 comments

In this MWE, The RowX symbol in the export and the enum definition both emit "Missing reference: RowX". This does not happen if a value is not supplied for an enum variant.

Edit: This also occurs with the short form without begin/end.

export RowX, RowY, RowZ, RowW

@enum Row begin
    RowX = 1
    RowY
    RowZ
    RowW
end

kanubacode avatar Jul 15 '22 13:07 kanubacode

I get the same behavior when using @with_kw from Parameters.jl to assign a default for some field.

using Parameters: @with_kw
@with_kw myType
    a = 1
    b
end

function do_something( mt::myType )
    return mt.a + mt.b
end

In both the type definition and the function definition the linter shows "Missing reference: a".

Tested in emacs/lsp-mode using Julia 1.7.3 and LanguageServer v4.3.1.

manuelbb-upb avatar Jul 19 '22 10:07 manuelbb-upb

That's not very surprising -- we don't (and can't easily) support arbitrary macros.

pfitzseb avatar Jul 19 '22 11:07 pfitzseb

Ah okay. I was surprised that it worked for field b, so I thought the "bug" related.

PS: For Base.@kwdef everything seems to work as expected, no "Missing reference" there.

manuelbb-upb avatar Jul 19 '22 11:07 manuelbb-upb