Closed koudelka closed 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)
inject
defs
encode/1
Encoder.encode/2
defs(_ \\ nil)
@root.defs
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%
opened https://github.com/bitwalker/exprotobuf/pull/9
When using the
inject
option, it looks like thedefs
function (https://github.com/bitwalker/exprotobuf/blob/master/lib/exprotobuf/define_message.ex#L87 ) loops infinitely.encode/1
callsdefs
(as an argument toEncoder.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: