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

The spec follows a spec with different name/arity #99

Open
yordis opened this issue Jun 8, 2022 · 9 comments · Fixed by #102
Open

The spec follows a spec with different name/arity #99

yordis opened this issue Jun 8, 2022 · 9 comments · Fixed by #102
Assignees
Labels
bug Something isn't working

Comments

@yordis
Copy link

yordis commented Jun 8, 2022

Original issue: josefs/Gradualizer#421 (comment)

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)

@erszcz erszcz added the triage Needs assessment whether a bug, enhancement, duplicate, ... label Jun 9, 2022
@Premwoik Premwoik self-assigned this Jun 13, 2022
@rodrigues
Copy link
Contributor

rodrigues commented Jun 24, 2022

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.

@yordis
Copy link
Author

yordis commented Jun 24, 2022

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 😄

@rodrigues
Copy link
Contributor

@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 🤔

@erszcz
Copy link
Member

erszcz commented Jun 27, 2022

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.

@yordis
Copy link
Author

yordis commented Sep 7, 2022

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.

@erszcz
Copy link
Member

erszcz commented Sep 8, 2022

@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.

@erszcz erszcz added bug Something isn't working and removed triage Needs assessment whether a bug, enhancement, duplicate, ... labels Sep 18, 2022
@erszcz
Copy link
Member

erszcz commented Sep 18, 2022

@yordis Could you confirm if #102 fixed this for you?

@yordis
Copy link
Author

yordis commented Sep 20, 2022

With the following SHA

"gradient": {:git, "https://github.com/esl/gradient.git", "a4169bde64eeda4a692654932cc9f0a3ab79b2d5", []},

It still is not working. Same issues as before

@erszcz
Copy link
Member

erszcz commented Sep 20, 2022

@yordis thanks, I'm reopening then.

@erszcz erszcz reopened this Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants