Cannot decompile a certain file to expanded
I attempted to run decompile on the following file:
https://github.com/Qqwy/elixir-type_check/blob/49bb2134f336ed2ec98535c7ecd7fa89e2d86b5d/lib/type_check/builtin.ex
There is quite a bit of macro trickery going on there, so it definitely is not the easiest module to decompile. There probably is some edge case being triggered, as we get the following order when running the mix task:
$ mix decompile TypeCheck.Builtin --to expanded
** (SyntaxError) nofile:11: syntax error before: '('
(elixir 1.10.3) lib/code.ex:654: Code.format_string!/2
lib/tasks/decompile.ex:135: Mix.Tasks.Decompile.format_elixir_info/2
(elixir 1.10.3) lib/enum.ex:783: Enum."-each/2-lists^foreach/1-0-"/2
(elixir 1.10.3) lib/enum.ex:783: Enum.each/2
(mix 1.10.3) lib/mix/task.ex:330: Mix.Task.run_task/3
(mix 1.10.3) lib/mix/cli.ex:82: Mix.CLI.run_task/2
I'd love to help out in tracking down this problem, but I don't know where to start with debugging the decompilation process. If you can give me any pointers, I'll gladly contribute a PR or two :heart: .
@Qqwy just hit the same error. It seems to be related to the Elixir code formatter tripping on the expanded code.
Feel free to clone it locally and comment out the Code.format_string! on line 135.
You can also use it from the Iex shell, to see what is going on. Here the call to decompile a router file in from a project in the parent folder:
Mix.Tasks.Decompile.run(["../_build/dev/lib/knowtrex/ebin/Elixir.MyAppWeb.Router.beam", "--to", "expanded"])
For me the decompiled code has a syntax error looking like this:
defp call (overridable 2)(conn, _opts) do
%{method: method, path_info: path_info, host: host} = conn = prepare(conn)
The (overridable 2) does not look valid. :)
@Qqwy I have looked into it and fixed the issue. Feel free to use my fork until it is fixed here:
- https://github.com/mindreframer/decompile