Skip to content

Crash in Macro.to_string #13102

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 Nov 13, 2023 · 1 comment
Closed

Crash in Macro.to_string #13102

lukaszsamson opened this issue Nov 13, 2023 · 1 comment

Comments

@lukaszsamson
Copy link
Contributor

Elixir and Erlang/OTP versions

1.15.5

Operating system

any

Current behavior

I noticed this stacktrace

an exception was raised:
    ** (FunctionClauseError) no function clause matching in anonymous fn_1 in Code.Normalizer.normalize_kw_blocks/4
        (elixir 1.15.5) <REDACTED: user-file-path>:453: anonymous fn({:catchall, [closing: [line: 323, column: 20], line: 323, column: 11], []}) in Code.Normalizer.normalize_kw_blocks_4
        (elixir 1.15.5) <REDACTED: user-file-path>:1693: Enum."-map_2-lists^map_1-1-"/2
        (elixir 1.15.5) <REDACTED: user-file-path>:1693: Enum."-map_2-lists^map_1-1-"/2
        (elixir 1.15.5) <REDACTED: user-file-path>:453: Code.Normalizer.normalize_kw_blocks/4
        (elixir 1.15.5) <REDACTED: user-file-path>:1359: Code.quoted_to_algebra/2
        (elixir 1.15.5) <REDACTED: user-file-path>:1186: Macro.to_string/1

I'm not sure what the argument to Macro.to_string/1 was but it was extracted from AST with this match that tries to get function heads

{defname, location, [{_, head_location, _} = fn_head | _]} when defname in [:def, :defp, :defmacro, :defmacrop, :defguard, :defguardp, :defdelegate] ->
  Macro.to_string(fn_head)

I'm not sure if this is related to #12922 (the fix for that landed in 1.15.6)

Expected behavior

No crash

@sabiwara
Copy link
Contributor

You're too fast @josevalim 😄

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

No branches or pull requests

3 participants