Skip to content

Conversation

@wingyplus
Copy link
Contributor

@wingyplus wingyplus commented Dec 23, 2020

Removing [] out of Protobuf.Protoc.Generator.Message.fmt_type/1 and
add [] into Protobuf.TypeUtil.enum_to_spec/3 when TYPE_MESSAGE is match
alongs with repeated true.

Fixes #132

def enum_to_spec(:TYPE_SINT64), do: "integer"
def enum_to_spec(_), do: "any"
def enum_to_spec(:TYPE_MESSAGE, type, true = _repeated), do: "#{type}.t"
def enum_to_spec(:TYPE_MESSAGE, type, true = _repeated), do: "[#{type}.t]"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just see that message type doesn't add | nil into generated type. Should we need to add into this patch?

Copy link
Collaborator

@whatyouhide whatyouhide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @wingyplus , sorry for the long wait! Could you rebase this on the master branch?


defp fmt_type(%{label: "repeated", type_enum: type_enum, type: type}) do
"[#{type_to_spec(type_enum, type, true)}]"
"#{type_to_spec(type_enum, type, true)}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be 👇 now?

Suggested change
"#{type_to_spec(type_enum, type, true)}"
type_to_spec(type_enum, type, true)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@whatyouhide This comment is apply. :)

Removing [] out of Protobuf.Protoc.Generator.Message.fmt_type/1 and
add [] into Protobuf.TypeUtil.enum_to_spec/3 when TYPE_MESSAGE is match
alongs with repeated true.

Fixes elixir-protobuf#132
@wingyplus
Copy link
Contributor Author

@whatyouhide thank you for reviewing my changes. The PR already rebase and apply your suggestion. Please kindly review again.

@whatyouhide whatyouhide merged commit 93c8a01 into elixir-protobuf:master Apr 17, 2021
@wingyplus wingyplus deleted the fix-enum-repeated branch April 17, 2021 16:57
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

Successfully merging this pull request may close these issues.

Repeated enum fields do not generate proper typespecs

3 participants