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

Add undefined to records typespec #1

Open
wants to merge 2 commits into
base: proto3
Choose a base branch
from

Conversation

varnerac
Copy link

I think this fixes the dialyzer issues, but I can't tell for sure. Referencing a fork of a fork to test it in Nucleus is a pain.

Defs, Opts) ->
OrUndefined = case get_mapping_and_unset_by_opts(Opts) of
records ->
case gpb:is_msg_proto3(MsgName, Defs) of
true -> "";
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think that this actually does what we want. Could you paste an example of the warning that you're trying to fix?

@varnerac
Copy link
Author

varnerac commented Jan 26, 2017

It generates .hrl files like this:

-record(datapoint,
        {device_id = <<>>       :: iodata(),        % = 1
         change_id = 0          :: integer(),       % = 2, 32 bits
         datapoint_ts = 0       :: integer(),       % = 3, 32 bits
         battery = 0            :: integer(),       % = 4, 32 bits
         location = undefined   :: #location{},     % = 5
         proto_name = <<>>      :: iodata(),        % = 6
         proto_buffer = <<>>    :: binary(),        % = 7
         event_type = <<>>      :: iodata(),        % = 8
         packet_id = 0          :: integer(),       % = 9, 32 bits
         event_id = 0           :: integer(),       % = 10, 32 bits
         server_ts = 0          :: integer()        % = 11, 32 bits
        }).

The location field defaults to undefined, which breaks the declared type spec of #location{}

It should look like this:

         location = undefined   :: #location{} | undefined,     % = 5

@evanmcc
Copy link
Owner

evanmcc commented Jan 26, 2017

OK, I see what you mean. I still don't think that your fix does the right thing. I'll add it to the list of stuff to fix when I finally get back to trying to get this merged upstream.

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.

2 participants