Skip to content

Macro.to_string creates invalid/incorrect code #13248

Description

@mhanberg

Elixir and Erlang/OTP versions

Erlang/OTP 26 [erts-14.1.1] [source] [64-bit] [smp:32:32] [ds:32:32:10] [async-threads:1] [jit:ns]

Elixir 1.16.0 (compiled with Erlang/OTP 26)

Operating system

Linux and macOS

Current behavior

iex(5)> quote do
...(5)> a = [do: c]
...(5)> end |> Macro.to_string |> IO.puts
a = :do => c

I noticed this while working on Spitfire. I piped the Spitfire produced AST into Macro.to_string, then pasted that into iex and saw this compile error, then reproduced using just quote/1

It seems to only reproduce when as an operand to the match operator, and when the key is specifically :do.

Expected behavior

iex(5)> quote do
...(5)> a = [do: c]
...(5)> end |> Macro.to_string |> IO.puts
a = [do: c]

Activity

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

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