Skip to content

Endless loop when collecting into a map #14311

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

Closed
lukaszsamson opened this issue Mar 5, 2025 · 4 comments
Closed

Endless loop when collecting into a map #14311

lukaszsamson opened this issue Mar 5, 2025 · 4 comments

Comments

@lukaszsamson
Copy link
Contributor

Elixir and Erlang/OTP versions

Erlang/OTP 26 [erts-14.2.5.8] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]

Elixir 1.18.2 (compiled with Erlang/OTP 26)

Operating system

macOS

Current behavior

This code hangs both in tests and iex

for k <- [:foo, :__struct__], into: %{}, do: {k, nil} 

The same code does not hang for other atoms (false, true) and values

Expected behavior

No hang and %{foo: nil, __struct__: nil} returned or ArgumentError.

@lukaszsamson
Copy link
Contributor Author

This also hangs:

%{__struct__: nil}

@sabiwara
Copy link
Contributor

sabiwara commented Mar 6, 2025

Seems to be when dispatching any protocol to %{__struct__: nil}:

  • inspect(%{__struct__: nil})
  • Enum.to_list(%{__struct__: nil})
iex> Inspect.impl_for %{__struct__: nil}
Inspect
# should be: Inspect.Any

@josevalim
Copy link
Member

We should fix so the concatenation returns Inspect.nil. I don't think we should special case any atom. :)

@josevalim
Copy link
Member

I will push a fix since I want to ship a new v1.18 :)

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

Successfully merging a pull request may close this issue.

3 participants