lexical-lsp / lexical

Lexical is a next-generation elixir language server
781 stars 77 forks source link

Hovering a commented function gives an error message #638

Closed Terbium-135 closed 3 months ago

Terbium-135 commented 4 months ago

Lexical: Latest available commit as of today

Elixir: Erlang/OTP 26 [erts-14.2.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit] Elixir 1.16.1 (compiled with Erlang/OTP 26)

Part of the source code:

    # |> Ecto.Multi.merge(fn %{insert_order: order} ->
    #   Ecto.Multi.new()
    #   |> Ecto.Multi.insert(:comment, Ecto.build_assoc(post, :comments))
    # end)
    |> Ecto.Multi.merge(fn %{insert_order: order} ->
      xupdate_meals(item_ids, order.updated_at)
    end)

Hovering over merge of the very first line containing # |> Ecto.Multi.merge gives following error:

Error - 14:40:20] Request textDocument/hover failed.
  Message: ** (ErlangError) Erlang error: {:exception, {:badmatch, nil}, [{LXical.RemoteControl.CodeIntelligence.Entity, :arity_at_position, 2, [file: ~c"lib/lexical/remote_control/code_intelligence/entity.ex", line: 273]}, {LXical.RemoteControl.CodeIntelligence.Entity, :resolve, 4, [file: ~c"lib/lexical/remote_control/code_intelligence/entity.ex", line: 112]}, {LXical.RemoteControl.CodeIntelligence.Entity, :resolve, 2, [file: ~c"lib/lexical/remote_control/code_intelligence/entity.ex", line: 32]}]}
    (kernel 9.2.1) erpc.erl:702: :erpc.call/5
    (lx_server 0.5.0) lib/lexical/server/provider/handlers/hover.ex:21: LXical.Server.Provider.Handlers.Hover.handle/2
    (lx_server 0.5.0) lib/lexical/server/provider/queue.ex:99: anonymous fn/2 in LXical.Server.Provider.Queue.State.as_task/2
    (elixir 1.16.1) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2
    (elixir 1.16.1) lib/task/supervised.ex:36: Task.Supervised.reply/4

  Code: -32603 
scohen commented 3 months ago

@Terbium-135 I've been unable to replicate this. Can you give me the code that causes this, and the location where it happens?

Moosieus commented 3 months ago

I'm able to replicate this in vscode with the following snippet, representing | for the hover position:

defmodule Scratch do

  def a_humble_pipe(x) do
    ["a humble pipe", x]
  end

  def another_humble_pipe(x) do
    ["another_humble_pipe", x]
  end

  def many_such_pipes() do
    "pipe"
    |> a_humble_pipe()
    # |> ano|ther_humble_pipe()
    |> a_humble_pipe()
  end
end