gradient
gradient copied to clipboard
The spec follows a spec with different name/arity
Original issue: https://github.com/josefs/Gradualizer/issues/421#issuecomment-1149618778
I am getting the following issues:
commands/accept_address_transfer.ex: The spec new/1 on line 5 follows a spec with different name/arity
commands/accept_address_transfer.ex: The spec put_aggregate_id/2 on line 5 follows a spec with different name/arity
commands/accept_address_transfer.ex: The spec put_aggregate_id/2 on line 5 doesn't match the function name/arity
domain/address_transfer.ex: The spec identifier/0 on line 10 doesn't match the function name/arity
Here is the code where it is happening:
defmodule AddressTransfers.AcceptAddressTransfer do
use OnePiece.Commanded.CommandHandler
use OnePiece.Commanded.Command, aggregate_identifier: :address_transfer_id
embedded_schema do
field :accepted_at, :utc_datetime_usec
end
# ...
end
defmodule AddressTransfers.AddressTransfer do
use OnePiece.Commanded.Entity, identifier: :address_transfer_id
embedded_schema do
end
# ....
end
I am using the following package to expand the macros: https://github.com/straw-hat-team/beam-monorepo/tree/master/apps/one_piece_commanded/lib/one_piece/commanded
It seems that all the methods added by the macro are not working or something, but I added the typespec correctly (as far as I can tell, my apologies if was something obvious)
This error also happens in gradient codebase itself, the following spec in line 64
fails:
@spec context_mapper_map(forms(), tokens(), options()) :: forms()
def context_mapper_map(forms, tokens, opts, mapper \\ &mapper/3)
lib/gradient/ast_specifier.ex:64: The spec context_mapper_map/3 doesn't match the function name/arity
This error is because of the optional argument. Once a typespec for it is added, it stops complaining:
@type mapper_fn() :: (term(), term(), term()-> term())
@spec context_mapper_map(forms(), tokens(), options(), mapper_fn()) :: forms()
I think it would help a lot in this case to show the spec and surrounding code, like I've seen in some other errors.
This error is because of the optional argument.
What optional argument are you referring to? IN the example I shared I didn't have any so I want to make sure I understood 😄
@yordis yeah now I've looked a bit more your code, indeed I don't see optional args missing in spec for your case, I guess the scenario in gradient was a valid one, your seems to me like a false positive 🤔
Indeed, I think @yordis's example raises a false positive. Alas, with macros generating code it might be hard to avoid all of these without fixing all macros, that's why we'll resolve to #102 to avoid false positives in such cases - it's not perfect, but a good start.
Hey peeps, any update on this one? I wish I could contribute, but I am not qualified today. Almost everything failing today is due to this one.
@yordis No progress on the fix yet. Alas, we have very limited bandwidth :/ However, you can mute this warning by using no_ex_check
option or --no-ex-check
command-line flag.
@yordis Could you confirm if #102 fixed this for you?
With the following SHA
"gradient": {:git, "https://github.com/esl/gradient.git", "a4169bde64eeda4a692654932cc9f0a3ab79b2d5", []},
It still is not working. Same issues as before
@yordis thanks, I'm reopening then.