Skip to content

Mix format on map keys nil/true/false mixed with non-atom keys #9771

@hypno2000

Description

@hypno2000

Environment

  • Elixir & Erlang/OTP versions (elixir --version):
    Erlang/OTP 22 [erts-10.6.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] [dtrace]
    Elixir 1.10.0 (compiled with Erlang/OTP 22)

  • Operating system:
    MacOS Catalina, 10.15.2

Current behavior

mix format will transform

%{
  :nil => "foo",
  :false => "foo",
  :true => "foo",
  "bar" => "foo"
}

to:

%{
  nil => "foo",
  false => "foo",
  true => "foo",
  "bar" => "foo"
}

and when running mix format again it will be formatted to:

%{
  nil: "foo",
  false: "foo",
  true: "foo",
  "bar" => "foo"
}

The code above will not compile anymore: syntax error before: "bar"

Expected behavior

  1. Mix format should output final format on first run
  2. The output of mix format should compile

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