Skip to content
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

Cannot convert from beam file #5

Open
dylan-chong opened this issue Dec 16, 2020 · 3 comments
Open

Cannot convert from beam file #5

dylan-chong opened this issue Dec 16, 2020 · 3 comments

Comments

@dylan-chong
Copy link

dylan-chong commented Dec 16, 2020

Using the command found on the readme

> ./beam_to_ex --beam /Users/Dylan/Development/solve/absinthe-3/_build/dev/lib/absinthe/ebin/Elixir.Scratch.beam
warning: not passing the :switches or :strict option to OptionParser is deprecated
  (elixir 1.11.0-rc.0) lib/option_parser.ex:607: OptionParser.build_config/1
  (elixir 1.11.0-rc.0) lib/option_parser.ex:231: OptionParser.parse/2
  (beam_to_ex 0.2.0) lib/beam_to_ex.ex:8: BeamToEx.parse_args/1
  (beam_to_ex 0.2.0) lib/beam_to_ex.ex:3: BeamToEx.main/1
  (elixir 1.11.0-rc.0) lib/kernel/cli.ex:124: anonymous fn/3 in Kernel.CLI.exec_fun/2

** (FunctionClauseError) no function clause matching in BeamToExAst.Translate.BeamToExAst.Remote.to_elixir/2

    The following arguments were given to BeamToExAst.Translate.BeamToExAst.Remote.to_elixir/2:

        # 1
        {:remote, [generated: true, location: 83], {:var, 83, :_@1}, {:atom, 83, :module}}

        # 2
        %{call_params: [], parents: [:call, :body_less_filter, :clause, :case, :remote, :call, :match, :body, :function]}

    lib/beam_to_ex_ast/remote.ex:8: BeamToExAst.Translate.BeamToExAst.Remote.to_elixir/2
    (elixir 1.11.0-rc.0) lib/enum.ex:1399: Enum."-map/2-lists^map/1-0-"/2
    lib/beam_to_ex_ast.ex:123: BeamToExAst.def_body_less_filter/2
    lib/beam_to_ex_ast/clause.ex:30: BeamToExAst.Translate.BeamToExAst.Clause.to_elixir/2
    (elixir 1.11.0-rc.0) lib/enum.ex:1399: Enum."-map/2-lists^map/1-0-"/2
    (elixir 1.11.0-rc.0) lib/enum.ex:1399: Enum."-map/2-lists^map/1-0-"/2
    lib/beam_to_ex_ast/case.ex:9: BeamToExAst.Translate.BeamToExAst.Case.to_elixir/2
    (elixir 1.11.0-rc.0) lib/enum.ex:1399: Enum."-map/2-lists^map/1-0-"/2
@olafura
Copy link
Owner

olafura commented Dec 16, 2020

Thank you for the bug report I'll take a look at it tomorrow

@olafura
Copy link
Owner

olafura commented Dec 21, 2020

@dylan-chong Can you try now I think I figured out the problem.

@dylan-chong
Copy link
Author

dylan-chong commented Dec 22, 2020

Am on latest master. new problem

> ./beam_to_ex --beam /Users/Dylan/Development/solve/absinthe-3/_build/dev/lib/absinthe/ebin/Elixir.Scratch.beam
warning: not passing the :switches or :strict option to OptionParser is deprecated
  (elixir 1.11.0-rc.0) lib/option_parser.ex:607: OptionParser.build_config/1
  (elixir 1.11.0-rc.0) lib/option_parser.ex:231: OptionParser.parse/2
  (beam_to_ex 0.2.1) lib/beam_to_ex.ex:8: BeamToEx.parse_args/1
  (beam_to_ex 0.2.1) lib/beam_to_ex.ex:3: BeamToEx.main/1
  (elixir 1.11.0-rc.0) lib/kernel/cli.ex:124: anonymous fn/3 in Kernel.CLI.exec_fun/2

** (FunctionClauseError) no function clause matching in anonymous fn/1 in Macro.block_to_string/2

    The following arguments were given to anonymous fn/1 in Macro.block_to_string/2:

        # 1
        {:&, [line: [generated: true, location: 79]], [{:error, [line: 79], [{:{}, [line: 79], [:badkey, :module, {:&, [line: 79], [1]}]}]}]}

    (elixir 1.11.0-rc.0) lib/macro.ex:1204: anonymous fn/1 in Macro.block_to_string/2
    (elixir 1.11.0-rc.0) lib/enum.ex:1496: anonymous fn/2 in Enum.map_join/3
    (elixir 1.11.0-rc.0) lib/enum.ex:3444: Enum.map_intersperse_list/3
    (elixir 1.11.0-rc.0) lib/enum.ex:3444: Enum.map_intersperse_list/3
    (elixir 1.11.0-rc.0) lib/enum.ex:1496: Enum.map_join/3
    (elixir 1.11.0-rc.0) lib/macro.ex:1199: Macro.kw_block_to_string/3
    (elixir 1.11.0-rc.0) lib/macro.ex:1192: anonymous fn/4 in Macro.kw_blocks_to_string/2
    (elixir 1.11.0-rc.0) lib/enum.ex:2185: Enum."-reduce/3-lists^foldl/2-0-"/3

EDIT: Maybe this beam file is broken. trying a different one

> ./beam_to_ex --beam /Users/Dylan/Development/solve/absinthe/_build/dev/lib/absinthe/ebin/Elixir.Absinthe.Schema.Notation.beam
warning: not passing the :switches or :strict option to OptionParser is deprecated
  (elixir 1.11.0-rc.0) lib/option_parser.ex:607: OptionParser.build_config/1
  (elixir 1.11.0-rc.0) lib/option_parser.ex:231: OptionParser.parse/2
  (beam_to_ex 0.2.1) lib/beam_to_ex.ex:8: BeamToEx.parse_args/1
  (beam_to_ex 0.2.1) lib/beam_to_ex.ex:3: BeamToEx.main/1
  (elixir 1.11.0-rc.0) lib/kernel/cli.ex:124: anonymous fn/3 in Kernel.CLI.exec_fun/2

** (ArgumentError) argument error
    :erlang.element(1, Absinthe.Middleware.Telemetry)
    lib/beam_to_ex_ast/cons.ex:16: BeamToExAst.Translate.BeamToExAst.Cons.get_line_number/1
    lib/beam_to_ex_ast/cons.ex:24: BeamToExAst.Translate.BeamToExAst.Cons.to_elixir/2
    lib/beam_to_ex_ast.ex:104: BeamToExAst.def_body/2
    lib/beam_to_ex_ast.ex:53: anonymous fn/4 in BeamToExAst.do_convert/2
    (elixir 1.11.0-rc.0) lib/enum.ex:1399: Enum."-map/2-lists^map/1-0-"/2
    (elixir 1.11.0-rc.0) lib/enum.ex:1399: Enum."-map/2-lists^map/1-0-"/2
    lib/beam_to_ex_ast.ex:48: BeamToExAst.do_convert/2

Different error.

On a simpler module this seems to work

defmodule Test do
  def expand_ast(ast, env) do
    Macro.prewalk(ast, fn
      {_, _, _} = node ->
        Macro.expand(node, env)

      node ->
        node
    end)
  end

  def test do
    IO.inspect("Hello")
  end
end

elixirc test.ex

 ./beam_to_ex --beam /Users/Dylan/Desktop/crap/Elixir.Test.beam
warning: not passing the :switches or :strict option to OptionParser is deprecated
  (elixir 1.11.0-rc.0) lib/option_parser.ex:607: OptionParser.build_config/1
  (elixir 1.11.0-rc.0) lib/option_parser.ex:231: OptionParser.parse/2
  (beam_to_ex 0.2.1) lib/beam_to_ex.ex:8: BeamToEx.parse_args/1
  (beam_to_ex 0.2.1) lib/beam_to_ex.ex:3: BeamToEx.main/1
  (elixir 1.11.0-rc.0) lib/kernel/cli.ex:124: anonymous fn/3 in Kernel.CLI.exec_fun/2

defmodule Test do
  def(expand_ast(_ast, _env)) do
    Macro.prewalk(_ast, fn
      {_, _, _} = _node ->
        Macro.expand(_node, _env)
      _node ->
        _node
    end)
  end
  def test() do
    IO.inspect("Hello")
  end
end

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

No branches or pull requests

2 participants