Skip to content

Autocomplete struct using %{struct | syntaxe makes iex crashes #14149

@GuillaumeMilan

Description

@GuillaumeMilan

Elixir and Erlang/OTP versions

Elixir: 1.17.3
OTP: 27.1

Operating system

OS X

Current behavior

Let's define in a iex terminal u as

u = %URI{}

then try to autocomplete the following line in iex

iex> %{u |

the terminal crashes as

*** ERROR: Shell process terminated! (^G to start new job) ***

17:07:13.693 [error] Process #PID<0.70.0> raised an exception
** (Protocol.UndefinedError) protocol Enumerable not implemented for %URI{scheme: nil, userinfo: nil, host: nil, port: nil, path: nil, query: nil, fragment: nil} of type URI (a struct). This protocol is implemented for the following type(s): Date.Range, File.Stream, Function, GenEvent.Stream, HashDict, HashSet, Hl7.Repeater, IO.Stream, Jason.OrderedObject, List, Map, MapSet, Range, Stream
    (elixir 1.17.3) lib/enum.ex:1: Enumerable.impl_for!/1
    (elixir 1.17.3) lib/enum.ex:166: Enumerable.reduce/3
    (elixir 1.17.3) lib/enum.ex:4423: Enum.reduce/3
    (iex 1.17.3) lib/iex/autocomplete.ex:366: IEx.Autocomplete.container_context_map_fields/3
    (iex 1.17.3) lib/iex/autocomplete.ex:108: IEx.Autocomplete.expand_code/2
    (kernel 10.1) group.erl:743: :group.get_line1/5
    (kernel 10.1) group.erl:527: :group.get_chars_loop/10
    (kernel 10.1) group.erl:222: :group.io_request/6

Expected behavior

The iex terminal should autocomplete as for any kind of maps

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