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

Strange behavior when adding code after forall #215

Open
pallix opened this issue Aug 29, 2022 · 2 comments
Open

Strange behavior when adding code after forall #215

pallix opened this issue Aug 29, 2022 · 2 comments

Comments

@pallix
Copy link

pallix commented Aug 29, 2022

I encountered this strange behaviour today. Given the following code:


    property "some property" do
      forall i <- integer() do
        IO.inspect(i, label: "i")
        test_some_property()
      end
    end

    property "some other property" do
      forall i <- integer() do
        IO.inspect(i, label: "ii")
        test_some_property()
      end
      test_some_other_property()
    end

    defp test_some_property do
      true
    end

    defp test_some_other_property do
      true
    end

only the code block with the label: i with be executed. Obviously it makes little sense to have test_some_other_property() after the forall but given my code was more complex than the example it took me a while to find the problem.

Is that the expected behaviour? Would it make sense to give a warning or error?

@alfert
Copy link
Owner

alfert commented Aug 30, 2022

Hi @pallix ,
nice catch, this is similar to #112. We should warn about that in the documentation. Since propcheck relies heavily on macros and code generation, it could be difficult to identify that situation (i.e. the Elixir compiler does not detect that situation, so we would have to do that by ourselves).

Happy to receive a pull request!

@pallix
Copy link
Author

pallix commented Aug 30, 2022

In #112 both code blocks are executed but here only the one external to the forall. Am I correct?

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

No branches or pull requests

2 participants