credo
credo copied to clipboard
Slash inside macro
Environment
1.6.4-ref.deletion.8140e31+uncommittedchanges
What were you trying to do?
x = 1
p = path(x / x)
where path
is a macro
Expected outcome
No warning
Actual outcome
┃ [W] ↗ Operation will always return 1.
Why do you think this should not raise an issue?
Your code x / x
is (on the surface) always resulting in the same result which Credo points out, unless I am missunderstanding you (note that you did not provide any explanation in this issue).
Hi, that's a good question.
Here path
is a macro. It accepts an AST and generated a code from it. So it does not necessary use this AST in a way Elixir would use it. For example, my project pathex uses it for notation for Access-like lenses
Actually, you can't make any assumptions about code which is passed into a macro as an argument. Sometimes this AST gets modified, and sometimes not.
You are right. So we will habe to find a way to statically derermine whether or not something is a function or a macro 👍
Closing this for age. As it never came up again, we can assume that there are not too many people encountering this.
If it becomes an issue again, we can refer to this issue 👍