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

Crash #571

Closed
benkeil opened this issue Jul 10, 2021 · 4 comments
Closed

Crash #571

benkeil opened this issue Jul 10, 2021 · 4 comments
Labels
wontfix This will not be worked on

Comments

@benkeil
Copy link

benkeil commented Jul 10, 2021

Environment

Erlang/OTP 24 [erts-12.0.3] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit] [dtrace]

Elixir 1.12.2 (compiled with Erlang/OTP 24)

Logs

[Error - 08:32:56] Request textDocument/completion failed.
  Message: an exception was raised:
    ** (FunctionClauseError) no function clause matching in String.slice/2
        (elixir 1.12.2) lib/string.ex:2086: String.slice("String.", %Inspect.Error{message: "got FunctionClauseError with message \"no function clause matching in Inspect.Range.inspect/2\" while inspecting %{__struct__: Range, first: 0, last: -2}"})
        (elixir_sense 2.0.0) lib/elixir_sense/core/source.ex:44: ElixirSense.Core.Source.split_module_and_hint/3
        (elixir_sense 2.0.0) lib/elixir_sense/providers/suggestion/reducers/type_specs.ex:43: ElixirSense.Providers.Suggestion.Reducers.TypeSpecs.add_types/5
        (elixir 1.12.2) lib/enum.ex:4280: Enumerable.List.reduce/3
        (elixir 1.12.2) lib/enum.ex:2431: Enum.reduce_while/3
        (elixir_sense 2.0.0) lib/elixir_sense/providers/suggestion.ex:112: ElixirSense.Providers.Suggestion.find/4
        (language_server 0.7.0) lib/language_server/providers/completion.ex:137: ElixirLS.LanguageServer.Providers.Completion.completion/4
        (language_server 0.7.0) lib/language_server/server.ex:770: anonymous fn/3 in ElixirLS.LanguageServer.Server.handle_request_async/2
  Code: -32000 

Reproduce

The code is from the elixir guide. When open autocomplete after String. in String.t()it crashes.

defmodule LousyCalculator do
  @typedoc """
  Just a number followed by a string.
  """
  @type number_with_remark :: {number, String.t()}

  @spec add(number, number) :: number_with_remark
  def add(x, y), do: {x + y, "You need a calculator to do that?"}

  @spec multiply(number, number) :: number_with_remark
  def multiply(x, y), do: {x * y, "It is like addition on steroids."}
end
@lukaszsamson
Copy link
Collaborator

@benkeil please post a project or a snippet that reproduces this crash.

@benkeil
Copy link
Author

benkeil commented Jul 10, 2021

There is a big snippet…

@lukaszsamson
Copy link
Collaborator

It looks like a regression in elixir standard library. I can reproduce it with elixir-ls compiled with elixir < 1.12 and run on 1.12. When I compile and run on 1.12 the error no longer happens.

@lukaszsamson
Copy link
Collaborator

The relevant fixes will be included in elixir >= 1.12.3. Consider upgrading to 1.12.3 when it's released or downgrading to 1.11.x. Theoretically we could workaround the issue by avoiding all elixir APIs using Range but IMO it's not worth the cost as it would touch elixir-ls and all its deps. This is another case whre our packaging approach is not optimal. See #115 for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants