jeremyjh / dialyxir

Mix tasks to simplify use of Dialyzer in Elixir projects.
Apache License 2.0
1.7k stars 140 forks source link

Failed to parse warning #263

Open gpad opened 5 years ago

gpad commented 5 years ago

I got this error:

Please file a bug in https://github.com/jeremyjh/dialyxir/issues with this message.

Failed to parse warning:
[{:<, 1}, {:atom_part, 1, 'V'}, {:atom_part, 1, 'p'}, {:atom_part, 1, 'a'}, {:atom_part, 1, 'y'}, {:atom_part, 1, 'o'}, {:atom_part, 1, 'u'}, {:atom_part, 1, 't'}, {:atom_part, 1, '@'}, {:int, 1, 1}, {:=, 1}, {:"#", 1}, {:"{", 1}, {:atom_full, 1, '\'result\''}, {:":=", 1}, {:"<<", 1}, {:int, 1, 69}, {:":", 1}, {:int, 1, 8}, {:atom_part, 1, '/'}, {:atom_part, 1, 'i'}, {:atom_part, 1, 'n'}, {:atom_part, 1, 't'}, {:atom_part, 1, 'e'}, {:atom_part, 1, 'g'}, {:atom_part, 1, 'e'}, {:atom_part, 1, 'r'}, {:atom_part, 1, '-'}, {:atom_part, 1, 'u'}, {:atom_part, 1, 'n'}, {:atom_part, 1, 'i'}, {:atom_part, 1, 't'}, {:":", 1}, {:int, 1, 1}, {:",", 1}, {:int, 1, 82}, {:":", 1}, {:int, 1, 8}, {:atom_part, 1, '/'}, {:atom_part, 1, 'i'}, {:atom_part, 1, 'n'}, {:atom_part, 1, 't'}, {:atom_part, 1, 'e'}, {:atom_part, 1, 'g'}, {:atom_part, 1, 'e'}, {:atom_part, 1, 'r'}, {:atom_part, 1, '-'}, {:atom_part, 1, ...}, {:atom_part, ...}, {...}, ...]

Legacy warning:
apps/wallet/lib/wallet/payment/we_chat/router.ex:208: The pattern <Vpayout@1 = #{'result':=<<69:8/integer-unit:1,82:8/integer-unit:1,82:8/integer-unit:1,79:8/integer-unit:1,82:8/integer-unit:1>>, '__struct__':='Elixir.Utils.Format.Wallet.PayOut', 'message':=_msg@1, 'provider_tx_code':=<<48:8/integer-unit:1,53:8/integer-unit:1>>}, #{'merchant_id':=_merchant_id@1, '__struct__':='Elixir.Utils.Format.Wallet.PayIn'}, 'query'> can never match the type <#{'__struct__':='Elixir.Utils.Format.Wallet.PayOut', 'additional_fields':=#{'error'=>'we_chat_error', 'time'=>binary(), 'tn'=>binary()}, 'auth_code':='nil', 'merchant_tx_code':='nil', 'message':=bitstring(), 'provider_tx_code':='nil' | binary(), 'result':=<<_:16,_:_*24>>, 'time_stamp':=_, 'user_id':='nil'},#{'__struct__':='Elixir.Utils.Format.Wallet.PayIn', 'timestamp':=_, _=>_},'reserve'>
jeremyjh commented 5 years ago

Can you confirm if this is still an issue in rc.4 ?

{:dialyxir, "~> 1.0.0-rc.4", only: [:dev], runtime: false}

asummers commented 5 years ago

Ya it will be, I didn't do anything to fix this in the last RC.

asummers commented 5 years ago

Hmm. This is fun. What shenanigans is this?

<<48:8/integer-unit:1,53:8/integer-unit:1>>
asummers commented 5 years ago

http://erlang.org/doc/reference_manual/expressions.html#bit_syntax

gpad commented 5 years ago

@jeremyjh The code in the meanwhile is changed and I'm not able to replicate the exact error but I get some similar one (with rc.4)

Please file a bug in https://github.com/jeremyjh/dialyxir/issues with this message.

Failed to parse warning:
[{:"(", 1}, {:atom_part, 1, 'C'}, {:atom_part, 1, 'e'}, {:atom_part, 1, 'r'}, {:atom_part, 1, 't'}, {:::, 1}, {:atom_part, 1, 'b'}, {:atom_part, 1, 'i'}, {:atom_part, 1, 'n'}, {:atom_part, 1, 'a'}, {:atom_part, 1, 'r'}, {:atom_part, 1, 'y'}, {:"(", 1}, {:")", 1}, {:|, 1}, {:"#", 1}, {:atom_full, 1, '\'OTPCertificate\''}, {:"{", 1}, {:"}", 1}, {:|, 1}, {:atom_part, 1, 'a'}, {:atom_part, 1, 't'}, {:atom_part, 1, 'o'}, {:atom_part, 1, 'm'}, {:"(", 1}, {:")", 1}, {:",", 1}, {:atom_part, 1, 'C'}, {:atom_part, 1, 'e'}, {:atom_part, 1, 'r'}, {:atom_part, 1, 't'}, {:atom_part, 1, 'C'}, {:atom_part, 1, 'h'}, {:atom_part, 1, 'a'}, {:atom_part, 1, 'i'}, {:atom_part, 1, 'n'}, {:::, 1}, {:"[", 1}, {:atom_part, 1, 'b'}, {:atom_part, 1, 'i'}, {:atom_part, 1, 'n'}, {:atom_part, 1, 'a'}, {:atom_part, 1, 'r'}, {:atom_part, 1, 'y'}, {:"(", 1}, {:")", 1}, {:"]", 1}, {:",", 1}, {:atom_part, ...}, {...}, ...]

Legacy warning:
apps/wallet/lib/wallet/payment/union_pay/crypto.ex:78: The call public_key:pkix_path_validation(Vroot_cert@1::{'Certificate' | 'CertificateList' | 'CertificationRequest' | 'DHParameter' | 'DSAPrivateKey' | 'ECPrivateKey' | 'EcpkParameters' | 'PrivateKeyInfo' | 'RSAPrivateKey' | 'RSAPublicKey' | 'SubjectPublicKeyInfo',binary(),'not_encrypted' | {string(),binary() | {{'PBEParameter',_,_},atom()} | {'PBES2-params',_,_}}} | {'Certificate',_,_,_} | {'OTPCertificate',_,_,_},[{'Certificate' | 'CertificateList' | 'CertificationRequest' | 'DHParameter' | 'DSAPrivateKey' | 'ECPrivateKey' | 'EcpkParameters' | 'PrivateKeyInfo' | 'RSAPrivateKey' | 'RSAPublicKey' | 'SubjectPublicKeyInfo',binary(),'not_encrypted' | {string(),binary() | {{'PBEParameter',_,_},atom()} | {'PBES2-params',_,_}}} | {'Certificate',_,_,_} | {'OTPCertificate',_,_,_},...],[]) breaks the contract (Cert::binary() | #'OTPCertificate'{} | atom(),CertChain::[binary()],Options::proplists:proplist()) -> {'ok',{PublicKeyInfo::term(),PolicyTree::term()}} | {'error',{'bad_cert',Reason::term()}}

or

Please file a bug in https://github.com/jeremyjh/dialyxir/issues with this message.

Failed to parse warning:
[{:"(", 1}, {:::, 1}, {:atom_part, 1, 'a'}, {:atom_part, 1, 'n'}, {:atom_part, 1, 'y'}, {:"(", 1}, {:")", 1}, {:",", 1}, {:::, 1}, {:atom_part, 1, 'a'}, {:atom_part, 1, 'n'}, {:atom_part, 1, 'y'}, {:"(", 1}, {:")", 1}, {:",", 1}, {:"[", 1}, {:"]", 1}, {:")", 1}]

Legacy warning:
apps/merchant_profile/lib/merchant_profile/rce/query.ex:67: The call 'Elixir.MerchantProfile.Rce.Query':health(_@1::any(),_@2::any(),[]) will never return since it differs in the 3rd argument from the success typing arguments: (any(),binary(),boolean())

or

Please file a bug in https://github.com/jeremyjh/dialyxir/issues with this message.

Failed to parse warning:
[{:"(", 1}, {:::, 1}, {:atom_part, 1, 'a'}, {:atom_part, 1, 'n'}, {:atom_part, 1, 'y'}, {:"(", 1}, {:")", 1}, {:",", 1}, {:::, 1}, {:atom_part, 1, 'a'}, {:atom_part, 1, 'n'}, {:atom_part, 1, 'y'}, {:"(", 1}, {:")", 1}, {:",", 1}, {:atom_full, 1, '\'nil\''}, {:",", 1}, {:"[", 1}, {:"]", 1}, {:")", 1}]

Legacy warning:
apps/merchant_profile/lib/merchant_profile/rce/query.ex:31: The call 'Elixir.MerchantProfile.Rce.Query':call(_@1::any(),_@2::any(),'nil',[]) breaks the contract ('Elixir.String':t(),endpoint(),map(),'Elixir.Keyword':t()) -> response()
________________________________________________________________________________
Please file a bug in https://github.com/jeremyjh/dialyxir/issues with this message.

Failed to parse warning:
[{:"(", 1}, {:::, 1}, {:atom_part, 1, 'a'}, {:atom_part, 1, 'n'}, {:atom_part, 1, 'y'}, {:"(", 1}, {:")", 1}, {:",", 1}, {:::, 1}, {:atom_part, 1, 'a'}, {:atom_part, 1, 'n'}, {:atom_part, 1, 'y'}, {:"(", 1}, {:")", 1}, {:",", 1}, {:"[", 1}, {:"]", 1}, {:")", 1}]

Legacy warning:
apps/merchant_profile/lib/merchant_profile/rce/query.ex:55: The call 'Elixir.MerchantProfile.Rce.Query':merchants(_@1::any(),_@2::any(),[]) will never return since it differs in the 3rd argument from the success typing arguments: (any(),binary(),boolean())
gpad commented 5 years ago

@jeremyjh some other issues with rc4

Please file a bug in https://github.com/jeremyjh/dialyxir/issues with this message.

Failed to parse warning:
[{:"(", 1}, {:atom_full, 1, '\'Elixir.String\''}, {:":", 1}, {:atom_part, 1, 't'}, {:"(", 1}, {:")", 1}, {:::, 1}, {:atom_part, 1, 'a'}, {:atom_part, 1, 'n'}, {:atom_part, 1, 'y'}, {:"(", 1}, {:")", 1}, {:")", 1}, {:->, 1}, {:atom_part, 1, 't'}, {:atom_part, 1, 'r'}, {:atom_part, 1, 'a'}, {:atom_part, 1, 'c'}, {:atom_part, 1, 'e'}, {:atom_part, 1, 'r'}, {:_, 1}, {:"fun(", 1}, {:")", 1}]

Legacy warning:
apps/utils/lib/utils/dynamic_fsm.ex:475: Type specification 'Elixir.DynamicFSM':default_tracer('Elixir.String':t()::any()) -> tracer_fun() is a supertype of the success typing: 'Elixir.DynamicFSM':default_tracer(_) -> fun(({'exit',_} | {'state_too_many_timeouts',atom() | tuple()} | {'state_crash',atom() | tuple(),_} | {'state_result',atom() | tuple(),_} | {'state_timeout',atom() | tuple(),non_neg_integer(),non_neg_integer()},#{'__struct__':='Elixir.DynamicFSM.Data', 'async':='nil' | map(), 'context':=_, 'state_result':=map(), 'states':=[any()], 'tracer':=fun((_,_) -> any()), 'transitions':=map()}) -> any())
________________________________________________________________________________
Please file a bug in https://github.com/jeremyjh/dialyxir/issues with this message.

Failed to parse warning:
[{:"(", 1}, {:atom_part, 1, 'e'}, {:atom_part, 1, 'v'}, {:atom_part, 1, 'e'}, {:atom_part, 1, 'n'}, {:atom_part, 1, 't'}, {:"(", 1}, {:")", 1}, {:",", 1}, {:atom_full, 1, '\'Elixir.DynamicFSM.Data\''}, {:":", 1}, {:atom_part, 1, 't'}, {:"(", 1}, {:")", 1}, {:",", 1}, {:atom_full, 1, '\'Elixir.String\''}, {:":", 1}, {:atom_part, 1, 't'}, {:"(", 1}, {:")", 1}, {:::, 1}, {:atom_part, 1, 'a'}, {:atom_part, 1, 'n'}, {:atom_part, 1, 'y'}, {:"(", 1}, {:")", 1}, {:")", 1}, {:->, 1}, {:atom_part, 1, 'a'}, {:atom_part, 1, 'n'}, {:atom_part, 1, 'y'}, {:"(", 1}, {:")", 1}]

Legacy warning:
apps/utils/lib/utils/dynamic_fsm.ex:481: Type specification 'Elixir.DynamicFSM':default_trace(event(),'Elixir.DynamicFSM.Data':t(),'Elixir.String':t()::any()) -> any() is a supertype of the success typing: 'Elixir.DynamicFSM':default_trace({'exit',_} | {'state_too_many_timeouts',atom() | tuple()} | {'state_crash',atom() | tuple(),_} | {'state_result',atom() | tuple(),_} | {'state_timeout',atom() | tuple(),non_neg_integer(),non_neg_integer()},#{'__struct__':='Elixir.DynamicFSM.Data', 'async':='nil' | #{'__struct__':='Elixir.DynamicFSM.Async', 'retries':=integer(), 'task':=#{'__struct__':='Elixir.Task', 'owner':=_, 'pid':=_, 'ref':=_}, 'timeout':=integer()}, 'context':=_, 'state_result':=map(), 'states':=[any()], 'tracer':=fun((_,#{'__struct__':='Elixir.DynamicFSM.Data', 'async':=_, 'context':=_, 'state_result':=_, 'states':=_, 'tracer':=_, 'transitions':=_}) -> 'ok'), 'transitions':=map()},fun((_) -> any())) -> any()

Just as info the issue was caused by a wrong spec definition

-  @spec default_trace(event(), %Data{}, String.t() :: any()) :: any()
+  @spec default_trace(event(), Data.t(), (String.t() -> any())) :: any()
-  @spec default_tracer(String.t() :: any()) :: tracer_fun()
+  @spec default_tracer((String.t() -> any())) :: tracer_fun()

AS you can see the last arguments should be defined as function but was defined as an argument of type any and of name String.t()

asummers commented 5 years ago

For my bookkeeping, there are a few issues here though I have not fully diagnosed all so this list may grow. I plan on fixing this week if I can.

dnsbty commented 5 years ago

It looks like my issue is the same as this one:

Please file a bug in https://github.com/jeremyjh/dialyxir/issues with this message.

Failed to format warning:
"@spec a(({:error, <<_ :: 64, _ :: size(8)>>} | {:ok, %NaiveDateTime{:calendar => atom(), :day => pos_integer(), :hour => non_neg_integer(), :microsecond => {_, _}, :minute => non_neg_integer(), :month => pos_integer(), :second => non_neg_integer(), :year => integer()}} | %NaiveDateTime{:calendar => atom(), :day => pos_integer(), :hour => non_neg_integer(), :microsecond => {_, _}, :minute => non_neg_integer(), :month => pos_integer(), :second => non_neg_integer(), :year => integer()}, <<_ :: 64, _ :: size(56)>>) :: {:error, :incompatible_calendars | :invalid_date | :invalid_format | :invalid_time | <<_ :: 64, _ :: size(8)>>} | {:ok, %NaiveDateTime{:calendar => atom(), :day => pos_integer(), :hour => non_neg_integer(), :microsecond => {_, _}, :minute => non_neg_integer(), :month => pos_integer(), :second => non_neg_integer(), :year => integer()}}) :: :ok\ndef a() do\n  :ok\nend\n"

Legacy warning:
lib/mix/tasks/reporting_export.ex:87: Type specification 'Elixir.Mix.Tasks.Reporting.Export':set_time({'ok','Elixir.NaiveDateTime':t()} | {'error','Elixir.String':t()} | 'Elixir.NaiveDateTime':t(),'Elixir.String':t()) -> {'ok','Elixir.NaiveDateTime':t()} | {'error',any()} is not equal to the success typing: 'Elixir.Mix.Tasks.Reporting.Export':set_time({'error',<<_:64,_:_*8>>} | {'ok',#{'__struct__':='Elixir.NaiveDateTime', 'calendar':=atom(), 'day':=pos_integer(), 'hour':=non_neg_integer(), 'microsecond':={_,_}, 'minute':=non_neg_integer(), 'month':=pos_integer(), 'second':=non_neg_integer(), 'year':=integer()}} | #{'__struct__':='Elixir.NaiveDateTime', 'calendar':=atom(), 'day':=pos_integer(), 'hour':=non_neg_integer(), 'microsecond':={_,_}, 'minute':=non_neg_integer(), 'month':=pos_integer(), 'second':=non_neg_integer(), 'year':=integer()},<<_:64,_:_*56>>) -> {'error','incompatible_calendars' | 'invalid_date' | 'invalid_format' | 'invalid_time' | <<_:64,_:_*8>>} | {'ok',#{'__struct__':='Elixir.NaiveDateTime', 'calendar':=atom(), 'day':=pos_integer(), 'hour':=non_neg_integer(), 'microsecond':={_,_}, 'minute':=non_neg_integer(), 'month':=pos_integer(), 'second':=non_neg_integer(), 'year':=integer()}}
asummers commented 5 years ago

@dnsbty Yours is a bit different. I see a potential fix for that. Do you mind recreating and running against this branch?

https://github.com/jeremyjh/dialyxir/tree/fix-contract-diff

Edit: Nope may be the same as the linked thread. Is not same as linked thread.

dnsbty commented 5 years ago

@asummers Yeah that took care of it! Thanks for taking on all of the work to make the dialyzer output more readable. Super awesome.

jannamamer commented 5 years ago

I have the same issue. Is this already fix?

jeremyjh commented 5 years ago

@jannamamer its fixed on master but hasn't been released on Hex yet.