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

Dialyzer error when specifying Queries in module attributes in compiled helpers #542

Closed
TheFirstAvenger opened this issue Jun 18, 2020 · 6 comments · Fixed by #543
Closed
Assignees

Comments

@TheFirstAvenger
Copy link
Contributor

TheFirstAvenger commented Jun 18, 2020

Example Repo: https://github.com/TheFirstAvenger/wallaby_dialyzer_issue

If you have compiled test helpers, and use module attributes to specify Queries, then functions that call fill_in, click, or assert_has will throw the Dialyzer "no return" error. These show up as errors in IDE tools like ElixirLS.

  @doc """
  This version has inline Queries.
  There is no dialyzer error on this version
  """
  def log_in_no_error(session) do
    session
    |> Browser.visit("/login")
    |> Browser.fill_in(Query.text_field("username"), with: "me")
    |> Browser.click(Query.css("button", text: "Log in"))
    |> Browser.assert_has(Query.css("h1", text: "Logged In!"))
  end

  @username_field Query.text_field("username")
  @log_in_button Query.css("button", text: "Log in")
  @logged_in_h1 Query.css("h1", text: "Logged In!")

  @doc """
  This version uses module atttributes for it's queries
  This results in the Dialyzer error "Function log_in_has_no_return/1 has no local return."
  """
  def log_in_has_no_return(session) do
    session
    |> Browser.visit("/login")
    |> Browser.fill_in(@username_field, with: "me")
    |> Browser.click(@log_in_button)
    |> Browser.assert_has(@logged_in_h1)
  end
@TheFirstAvenger TheFirstAvenger changed the title Dialyzer error when specifying Queries in module variables in compiled helpers Dialyzer error when specifying Queries in module attributes in compiled helpers Jun 18, 2020
@michallepicki
Copy link
Contributor

Thanks for the repro repository!

I'll look into it - I am familiar with Wallaby codebase and I have some experience fixing dialyzer in application code. So far I have been ignoring dialyzer issues in my projects wallaby tests - this is a good starting point to change this :)

@michallepicki
Copy link
Contributor

@TheFirstAvenger This should be fixed on master now, to confirm you can try it out by specifying {:wallaby, github: "elixir-wallaby/wallaby", only: :test}, in your project

@mhanberg
Copy link
Member

I can publish a patch release once you've confirmed it works @TheFirstAvenger.

Thanks for taking the time to open an issue and create a bug demo project, we appreciate it!

🍻

@TheFirstAvenger
Copy link
Contributor Author

@mhanberg Confirmed, that fixed it, thanks!

@mhanberg
Copy link
Member

@TheFirstAvenger the fix has been released with v0.26.2

@TheFirstAvenger
Copy link
Contributor Author

@mhanberg Thank you!

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 a pull request may close this issue.

3 participants