-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Fix errors with ref/4 IEx helper #8016
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
Fix errors with ref/4 IEx helper #8016
Conversation
In addition, include documentation for that function.
@fertapric we don't have doctests enabled for this module, so we need to add some unit tests too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fertapric ping!
I just wanted to mention that I did not forget about this one :) I was doing some tests using the new iex(1)> make_ref()
#Reference<0.3013689594.4010541059.29671>
iex(2)> :erlang.list_to_ref('#Ref<0.3013689594.4010541059.29671>')
#Reference<0.3013689594.4010541059.29671>
iex(3)> :erlang.list_to_ref('#Ref<3.3013689594.4010541059.29671>')
#Reference<0.3013689594.4010541059.29671>
iex(4)> :erlang.list_to_ref('#Ref<0.301.401054.29671>')
** (ArgumentError) argument error
:erlang.list_to_ref('#Ref<0.301.401054.29671>') (4) shows that not all possible number combinations are valid to create a However, I was not expecting (3) to return a modified reference. I would expect an I looked a bit in the Erlang/OTP codebase, and I'm currently checking these parts of the codebase:
According to that, I also suspect that I was inspecting the code to check if it would be an error that should be reported upstream. But I don't have that much time to investigate :( I thought maybe you know a little more about it and you could give me some more details or tips? cc @michalmuskala |
Either way, I'll finish this PR today. Bug or not, Elixir is not responsible of it :) |
@fertapric I believe the first part is the node reference. 0 is local node. |
Yeah, I believe it is. I would expect it to fail, similar to what happens for external PIDs or ports |
@josevalim Tests added. Btw, I found out that iex(1)> :erlang.list_to_pid('<0.21.32>')
#PID<0.21.32>
iex(2)> :erlang.list_to_pid('<3.21.32>')
#PID<0.21.32> However, if I do the same experiments in a cluster of nodes: iex(n2@127.0.0.1)37> :erlang.list_to_pid('<3.21.32>')
** (ArgumentError) argument error
:erlang.list_to_pid('<3.21.32>')
iex(n2@127.0.0.1)37> :erlang.list_to_pid('<0.21.32>')
#PID<0.21.32>
iex(n2@127.0.0.1)38> :erlang.list_to_ref('#Ref<3.1.2.3>')
** (ArgumentError) argument error
:erlang.list_to_ref('#Ref<3.1.2.3>')
iex(n2@127.0.0.1)38> :erlang.list_to_ref('#Ref<0.1.2.3>')
#Reference<0.1.2.3> 🤷♂️ |
Thank you! ❤️ |
* Fix errors with ref/4 IEx helper In addition, include documentation for that function. * Update helpers.ex * Add IEx.Helpers.ref/* tests * Use examples that do not return ArgumentError Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
This reverts commit b9d6f4f.
In addition, I've included the documentation for that function.
Before:
After:
These functions were included in this commit