Skip to content

Conversation

hauleth
Copy link
Contributor

@hauleth hauleth commented Feb 8, 2019

Earlier this outputted error messages when loaded module that existed
with different casing, ex.:

iex> i Datetime

Caused errors to be shown. Now this checks if there is module file
defines module with the same name as the provided atom to prevent such
cases.

Close #8780

Earlier this outputted error messages when loaded module that existed
with different casing, ex.:

    iex> i Datetime

Caused errors to be shown. Now this checks if there is module file
defines module with the same name as the provided atom to prevent such
cases.
@hauleth hauleth force-pushed the fix/iex-module-inspect-case-sensitivity branch from 54d3917 to c4164c7 Compare February 8, 2019 12:42
@hauleth
Copy link
Contributor Author

hauleth commented Feb 8, 2019

I am not sure how we could test that on case-sensitive systems so there are no tests. If someone have any idea then I am open to it.

@whatyouhide
Copy link
Member

@hauleth could we write a test for this that would just do nothing on case-sensitive systems so that at least when the test is running on case-insensitive systems we are testing the correct behaviour?

@hauleth
Copy link
Contributor Author

hauleth commented Feb 8, 2019

@whatyouhide I can write one like that.

@josevalim
Copy link
Member

Looks great, just a test and it should be good to go. I don't think the test needs to check for the filesystem because for case sensitive ones we will never show the warning either.

@hauleth
Copy link
Contributor Author

hauleth commented Feb 8, 2019

@josevalim done

Code.ensure_loaded?(atom)

{^atom, beam, _path} ->
module_name =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about using Keyword.fetch to avoid the comment and the default 0 value?

beam_info = :beam_lib.info(beam)

case Keyword.fetch(beam_info, :module) do
  {:ok, ^atom} -> true
  _ -> false
end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to match?/2.

@josevalim
Copy link
Member

josevalim commented Feb 8, 2019 via email

@hauleth
Copy link
Contributor Author

hauleth commented Feb 8, 2019

@josevalim right, I have missed that.


{^atom, beam, _path} ->
info = :beam_lib.info(beam)

Copy link
Member

@whatyouhide whatyouhide Feb 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would kill this line ✂️

Suggested change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally always separate variables and "main body" of the function, but this is up to you.

@josevalim josevalim merged commit 352dd7f into elixir-lang:master Feb 9, 2019
@josevalim
Copy link
Member

❤️ 💚 💙 💛 💜

@hauleth hauleth deleted the fix/iex-module-inspect-case-sensitivity branch February 26, 2019 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants