Skip to content

No suggestions for @speced function params #1125

Open
@SergeyMosin

Description

@SergeyMosin

Environment

Elixir & Erlang versions (elixir --version):

Erlang/OTP 26 [erts-14.2.5.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]
Elixir 1.17.3 (compiled with Erlang/OTP 26)

VSCode ElixirLS version: v0.24.2
Operating System Version: Ubuntu 22.04.5 LTS

Troubleshooting

  • Restart your editor (which will restart ElixirLS) sometimes fixes issues
  • Stop your editor, remove the entire .elixir_ls directory, then restart your editor

Details

Given this code:

defmodule MyMod do
  @type t :: %MyMod{
          id: pos_integer(),
          name: binary()
        }
  defstruct id: 0,
            name: ""

  @spec hello1(person :: MyMod.t()) :: MyMod.t()
  defp hello1(person) do
    IO.inspect(person)
  end

  @spec hello2(person :: MyMod.t()) :: MyMod.t()
  defp hello2(%MyMod{} = person) do
    IO.inspect(person)
  end

  @spec hello3(person :: MyMod.t()) :: MyMod.t()
  defp hello3(person) do
    p1 = hello1(person)
    IO.inspect(p1)
  end

  def say_hello() do
    person = %MyMod{
      id: 123,
      name: "Bob"
    }

    hello1(person)
    hello2(person)
    hello3(person)
  end
end

Problem

Autocomplete/suggestions for the person variable do not work in the hello1() function
image

Expected result

Autocomplete/suggestions should work for the person variable in hello1() the same way they work in the hello2() function
image

Relevant info

Strangely enough, suggestions work for the p1 variable in the hello3() function
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions