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

MethodError: no method matching Union{Int64, String}(::String) #651

Closed
gdkrmr opened this issue Apr 27, 2020 · 9 comments · Fixed by #821
Closed

MethodError: no method matching Union{Int64, String}(::String) #651

gdkrmr opened this issue Apr 27, 2020 · 9 comments · Fixed by #821

Comments

@gdkrmr
Copy link

gdkrmr commented Apr 27, 2020

I think this fails because "initializationOptions": null,. LanguageServer.jl should be able to handle this, the protocol specification says:

interface InitializeParams extends WorkDoneProgressParams {

...

        /**
	 * User provided initialization options.
	 */
	initializationOptions?: any;

...

}

Stacktrace:

ERROR: MethodError: no method matching Union{Int64, String}(::String)ERROR: 
Stacktrace:TypeError: in new, expected Array{Symbol,1}, got Nothing

Stacktrace: [1] LanguageServer.InitializeParams
( [1] deserialize::(Dict{String,Any}):: at Serialization/home/gkraemer/progs/julia/lsp-julia/languageserver/LanguageServer/src/protocol/initialize.jl:111.Serializer{IOStream}, 
 [2] parse_params::(DataType):: at Type/home/gkraemer/progs/julia/julia-1.4/usr/share/julia/stdlib/v1.4/Serialization/src/Serialization.jl:1315{Val{:initialize}}, 
 [2] handle_deserialize::(Dict{String,Any}):: at Serialization/home/gkraemer/progs/julia/lsp-julia/languageserver/LanguageServer/src/requests/init.jl:123.Serializer{IOStream}, 
 [3] parse::(Int32):: at Type/home/gkraemer/progs/julia/julia-1.4/usr/share/julia/stdlib/v1.4/Serialization/src/Serialization.jl:799{LanguageServer.JSONRPC.Request}, 
 [3] deserialize::(Dict{String,Any}):: at Serialization/home/gkraemer/progs/julia/lsp-julia/languageserver/LanguageServer/src/jsonrpc.jl:46.Serializer{IOStream}, 
 [4] run::(DataType):: at LanguageServerInstance/home/gkraemer/progs/julia/julia-1.4/usr/share/julia/stdlib/v1.4/Serialization/src/Serialization.jl:1309)
 at  [4] /home/gkraemer/progs/julia/lsp-julia/languageserver/LanguageServer/src/languageserverinstance.jl:236handle_deserialize
( [5] top-level scope:: at Serializationnone:1.
Serializer
Process julia-ls stderr finished

lsp-mode is sending the following:

[Trace - 01:53:34 PM] Sending request 'initialize - (1)'.
Params: {
  "processId": null,
  "rootPath": "/home/gkraemer/.julia/dev/Base58",
  "clientInfo": {
    "name": "emacs",
    "version": "GNU Emacs 26.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.18.9)\n of 2019-08-30"
  },
  "rootUri": "file:///home/gkraemer/.julia/dev/Base58",
  "capabilities": {
    "workspace": {
      "workspaceEdit": {
        "documentChanges": true,
        "resourceOperations": [
          "create",
          "rename",
          "delete"
        ]
      },
      "applyEdit": true,
      "symbol": {
        "symbolKind": {
          "valueSet": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
            14,
            15,
            16,
            17,
            18,
            19,
            20,
            21,
            22,
            23,
            24,
            25,
            26
          ]
        }
      },
      "executeCommand": {
        "dynamicRegistration": false
      },
      "didChangeWatchedFiles": {
        "dynamicRegistration": true
      },
      "workspaceFolders": true,
      "configuration": true
    },
    "textDocument": {
      "declaration": {
        "linkSupport": true
      },
      "definition": {
        "linkSupport": true
      },
      "implementation": {
        "linkSupport": true
      },
      "typeDefinition": {
        "linkSupport": true
      },
      "synchronization": {
        "willSave": true,
        "didSave": true,
        "willSaveWaitUntil": true
      },
      "documentSymbol": {
        "symbolKind": {
          "valueSet": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
            14,
            15,
            16,
            17,
            18,
            19,
            20,
            21,
            22,
            23,
            24,
            25,
            26
          ]
        },
        "hierarchicalDocumentSymbolSupport": true
      },
      "formatting": {
        "dynamicRegistration": true
      },
      "rangeFormatting": {
        "dynamicRegistration": true
      },
      "rename": {
        "dynamicRegistration": true,
        "prepareSupport": true
      },
      "semanticHighlightingCapabilities": {
        "semanticHighlighting": false
      },
      "codeAction": {
        "dynamicRegistration": true,
        "isPreferredSupport": true,
        "codeActionLiteralSupport": {
          "codeActionKind": {
            "valueSet": [
              "",
              "quickfix",
              "refactor",
              "refactor.extract",
              "refactor.inline",
              "refactor.rewrite",
              "source",
              "source.organizeImports"
            ]
          }
        }
      },
      "completion": {
        "completionItem": {
          "snippetSupport": true,
          "documentationFormat": [
            "markdown"
          ]
        },
        "contextSupport": true
      },
      "signatureHelp": {
        "signatureInformation": {
          "parameterInformation": {
            "labelOffsetSupport": true
          }
        }
      },
      "documentLink": {
        "dynamicRegistration": true,
        "tooltipSupport": true
      },
      "hover": {
        "contentFormat": [
          "markdown",
          "plaintext"
        ]
      },
      "foldingRange": {
        "dynamicRegistration": true
      },
      "callHierarchy": {
        "dynamicRegistration": false
      },
      "publishDiagnostics": {
        "relatedInformation": true,
        "tagSupport": {
          "valueSet": [
            1,
            2
          ]
        },
        "versionSupport": true
      }
    },
    "window": {
      "workDoneProgress": true
    }
  },
  "initializationOptions": null,
  "workDoneToken": "1"
}
@gdkrmr
Copy link
Author

gdkrmr commented May 2, 2020

I have done some digging and it comes down to the following:

julia> LanguageServer.ProgressToken("1")
ERROR: MethodError: no method matching Union{Int64, String}(::String)
Stacktrace:
 [1] top-level scope at REPL[17]:1
 [2] eval(::Module, ::Any) at ./boot.jl:331
 [3] eval_user_input(::Any, ::REPL.REPLBackend) at /home/gkraemer/progs/julia/julia-1.4/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86
 [4] run_backend(::REPL.REPLBackend) at /home/gkraemer/.julia/packages/Revise/C272c/src/Revise.jl:1075
 [5] top-level scope at REPL[1]:0

julia> 

ProgressToken is an alias for Union{Int, String} and has no constructor.

@jipolanco
Copy link

I have the same issue on neovim.

A possible fix, which seems to work for me, is to modify the InitializeParams constructor, replacing ProgressToken(dict["workDoneToken"]) with convert(ProgressToken, dict["workDoneToken"]). But I agree, a better solution would be to define a ProgressToken constructor that does this.

@non-Jedi non-Jedi changed the title still not working with lsp-julia and Julia 1.4 MethodError: no method matching Union{Int64, String}(::String) Jun 15, 2020
@StanczakDominik
Copy link

I have the same issue on neovim.

A possible fix, which seems to work for me, is to modify the InitializeParams constructor, replacing ProgressToken(dict["workDoneToken"]) with convert(ProgressToken, dict["workDoneToken"]). But I agree, a better solution would be to define a ProgressToken constructor that does this.

I can confirm that this seems to work for me as well, using neovim.

StanczakDominik added a commit to StanczakDominik/LanguageServer.jl that referenced this issue Aug 17, 2020
@ordicker
Copy link

I have a navie question about this problem.
How come this problem isn't present in vscode but happened in all (I think) other editors?

@gdkrmr
Copy link
Author

gdkrmr commented Aug 20, 2020

Good question 👍 IMO the problem lies somewhere in the communication between lsp-mode and the language server process. lsp-mode must do something differently than julia-vscode but I have no idea what and don't want to invest the time in learning how to debug both lsp-mode and julia-vscode.

@ordicker
Copy link

If that was the case (lsp-mode only) I would suspect that the problem is at lsp-mode, but It happened also with neovim so I don't know.

I would love to help, but I'm not sure how.

@hexaeder
Copy link

hexaeder commented Oct 18, 2020

EDIT: Nevermind, I've missinterpreted the Release notes, seems like the fix is not actually released in 3.2.0.

Unfortunately, the problem is still present for me on 3.2.0. I'm using lsp-julia as part of the Julia layer for spacemacs. I've tried with the shipped LSP as well as with the manual installed package in the standard environment.

Process julia-ls stderr finished
ERROR: [ Info: Indexing DifferentialEquations...
MethodError: no method matching Union{Int64, String}(::String)
Stacktrace:
 [1] LanguageServer.InitializeParams(::Dict{String,Any}) at /home/hw/.julia/packages/LanguageServer/y1ebo/src/protocol/initialize.jl:111
 [2] dispatch_msg(::JSONRPC.JSONRPCEndpoint, ::JSONRPC.MsgDispatcher, ::Dict{String,Any}) at /home/hw/.julia/packages/JSONRPC/1Kq3H/src/typed.jl:64
 [3] run(::LanguageServerInstance) at /home/hw/.julia/packages/LanguageServer/y1ebo/src/languageserverinstance.jl:308
 [4] top-level scope at none:1

Process julia-ls stderr finished

This log is from julia-ls:stderr buffer. The refered LanguageServer package is up to date:

~$ cat .julia/packages/LanguageServer/y1ebo/Project.toml | grep version
version = "3.2.0"

@XaydBayeck
Copy link

@hexaeder You can change to 3.2.1-DEV by this way temporarily.

el .julia/packages/LanguageServer
drwxr-xr-x - sid 30 9月  16:33 LPqF6
drwxr-xr-x - sid 20 10月 14:18 y1ebo
drwxr-xr-x - sid 18 9月  10:48 y1ebo.back

copy the LPqF6 to cover y1ebo

But I'm not sure it's usafull for you, maybe you need to check the source in LPqF6 first.

@Gijs-Koot
Copy link

I am using lsp-julia on emacs, I had this same problem. I solved this for now by installing the master branch directly with

(@v1.5) pkg> add https://github.com/julia-vscode/LanguageServer.jl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants