-
Notifications
You must be signed in to change notification settings - Fork 42
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
Multiple forall in a property result in unexpected behaviour #112
Comments
The behaviour is exactly how it is implemented :-) It is the simple situation where you have a function with two expressions in the body. Only the latter will be the result: def foo()
3
5
end Function |
Doesn’t Elixir warn that 3 is an unused value though? Surely there’s a way to emit this warning as well when using macros like forall? |
@fenollp, I don't think so. Macros generate an AST and do not inject Elixir source code as Erlang macros would do. So, the first steps of source code analysis within the Elixir compiler are not activated for the generated AST fragment. This is my general experience of writing macros. We could do something like implement it by ourselves, but this becomes difficult quickly when you think of nested What we certainly can do is to add a little statement within the docs of the property to make clear that a property is simply a function with a body. The result of the body is evaluated by the property macros and there is no magic happening (regarding the expecting a single value, not the mechanics of properties and the like 😄) |
I think the warnings about unused constructed values are generated by the compiler app and they get silenced when generating AST with the annotation “generated: true”.
It is quite possible that none of these options is possible given today’s semantics of Elixir in which case I would strongly encourage opening an issue on the language repo directly, as this sounds like an important enough feature to require the semantics. |
When multiple
forall
or similar properties are used within aproperty
, only the result of the lastforall
is relevant to the test result:This might come as a surprise to unexpecting users. PropCheck should probably warn about this.
The text was updated successfully, but these errors were encountered: