bitwalker / exprotobuf

Protocol Buffers in Elixir made easy!
Apache License 2.0
486 stars 69 forks source link

Infinite loop upon encode/1 with inject: true. #8

Closed koudelka closed 9 years ago

koudelka commented 9 years ago

When using the inject option, it looks like the defs function (https://github.com/bitwalker/exprotobuf/blob/master/lib/exprotobuf/define_message.ex#L87 ) loops infinitely. encode/1 calls defs (as an argument to Encoder.encode/2), defs(_ \\ nil) responds and calls @root.defs (itself)

Should injected modules also get the global defs helper from https://github.com/bitwalker/exprotobuf/blob/master/lib/exprotobuf/builder.ex#L77?

Test case below:

defmodule Basic do
  use Protobuf, from: Path.expand("../test/proto/basic.proto", __DIR__), only: :Basic, inject: true
end
Interactive Elixir (1.0.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Basic.new
%Basic{args: nil, f1: nil, f2: nil, type: nil}
iex(2)> Basic.new |> Basic.encode

BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
       (v)ersion (k)ill (D)b-tables (d)istribution
^C%
koudelka commented 9 years ago

opened https://github.com/bitwalker/exprotobuf/pull/9