{"action":"opened","issue":{"url":"https://api.github.com/repos/bitwalker/exprotobuf/issues/8","labels_url":"https://api.github.com/repos/bitwalker/exprotobuf/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/bitwalker/exprotobuf/issues/8/comments","events_url":"https://api.github.com/repos/bitwalker/exprotobuf/issues/8/events","html_url":"https://github.com/bitwalker/exprotobuf/issues/8","id":63331938,"number":8,"title":"Infinite loop upon encode/0 with inject: true.","user":{"login":"koudelka","id":30394,"avatar_url":"https://avatars.githubusercontent.com/u/30394?v=3","gravatar_id":"","url":"https://api.github.com/users/koudelka","html_url":"https://github.com/koudelka","followers_url":"https://api.github.com/users/koudelka/followers","following_url":"https://api.github.com/users/koudelka/following{/other_user}","gists_url":"https://api.github.com/users/koudelka/gists{/gist_id}","starred_url":"https://api.github.com/users/koudelka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koudelka/subscriptions","organizations_url":"https://api.github.com/users/koudelka/orgs","repos_url":"https://api.github.com/users/koudelka/repos","events_url":"https://api.github.com/users/koudelka/events{/privacy}","received_events_url":"https://api.github.com/users/koudelka/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-20T23:34:11Z","updated_at":"2015-03-20T23:34:11Z","closed_at":null,"body":"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` calls `Encoder.encode/2`, which calls `defs`, `defs(_ \\\\ nil)` responds and calls `@root.defs` (itself)\r\n\r\nShould injected modules also get the global defs helper from https://github.com/bitwalker/exprotobuf/blob/master/lib/exprotobuf/builder.ex#L77?\r\n\r\nTest case below:\r\n\r\n```elixir\r\ndefmodule Basic do\r\n  use Protobuf, from: Path.expand(\"../test/proto/basic.proto\", __DIR__), only: :Basic, inject: true\r\nend\r\n```\r\n\r\n```\r\nInteractive Elixir (1.0.3) - press Ctrl+C to exit (type h() ENTER for help)\r\niex(1)> Basic.new\r\n%Basic{args: nil, f1: nil, f2: nil, type: nil}\r\niex(2)> Basic.new |> Basic.encode\r\n\r\nBREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded\r\n       (v)ersion (k)ill (D)b-tables (d)istribution\r\n^C%\r\n```"}}