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

Use === instead of == where appropriate #18853

Closed
wants to merge 2 commits into from
Closed

Use === instead of == where appropriate #18853

wants to merge 2 commits into from

Conversation

nalimilan
Copy link
Member

Continuation of #16764.

@@ -528,7 +528,7 @@ end
function set_ssl_cert_locations(cert_loc)
cert_file = isfile(cert_loc) ? cert_loc : Cstring(C_NULL)
cert_dir = isdir(cert_loc) ? cert_loc : Cstring(C_NULL)
cert_file == C_NULL && cert_dir == C_NULL && return
cert_file === C_NULL && cert_dir === C_NULL && return
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks wrong.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch. Is === Cstring(C_NULL) OK?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe just remove the Cstring above.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds better indeed.

Copy link
Contributor

@yuyichao yuyichao Jan 31, 2017

Choose a reason for hiding this comment

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

This is still wrong. The function also looks very strange. Is it actually setting the envs to "Cstring(0x0000000000000000)"?

julia> ENV["AAA"] = Cstring(C_NULL)
Cstring(0x0000000000000000)

julia> ENV["AAA"]
"Cstring(0x0000000000000000)"

The setting of the ENV should probably just be folded with the isdir/isfile check (can they possibly both pass?) and clear the corresponding variable if necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

Funny. Cc: @simonbyrne who recently worked on libgit2.

@@ -786,8 +786,8 @@ mktempdir() do dir
rethrow(err)
finally
rm(logfile)
sshp !== nothing && kill(sshp)
agentp !== nothing && kill(agentp)
sshp !=== nothing && kill(sshp)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is disabled but is also wrong.

@@ -385,12 +385,12 @@ function exprresolve(ex::Expr)
can_eval, result = exprresolve_arith(ex)
if can_eval
return result
elseif ex.head == :call && (ex.args[1] == :+ || ex.args[1] == :-) && length(ex.args) == 3 && ex.args[3] == 0
elseif ex.head === :call && (ex.args[1] === :+ || ex.args[1] === :-) && length(ex.args) == 3 && ex.args[3] === 0
Copy link
Contributor

Choose a reason for hiding this comment

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

this could be a slight behavior change. wonder where this happens, there might be types that aren't closed under addition where this is invalid

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, I'm not following (I don't know what that code does). Are you talking about the === 0 part?

Copy link
Contributor

Choose a reason for hiding this comment

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

It used to accept anything that's == 0 as ex.args[3].

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, that I understand. I'll change it back unless we're 100% sure that's not an issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

@timholy Do you think this is OK? From the comment on line 384, it seems this should only handle literal 0, so should be fine.

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

This is a behavior change, which is not the purpose of this commit, so I think it should be changed back.

@@ -385,12 +385,12 @@ function exprresolve(ex::Expr)
can_eval, result = exprresolve_arith(ex)
if can_eval
return result
elseif ex.head == :call && (ex.args[1] == :+ || ex.args[1] == :-) && length(ex.args) == 3 && ex.args[3] == 0
elseif ex.head === :call && (ex.args[1] === :+ || ex.args[1] === :-) && length(ex.args) == 3 && ex.args[3] === 0
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

This is a behavior change, which is not the purpose of this commit, so I think it should be changed back.

@nalimilan
Copy link
Member Author

I had completely forgotten about this PR. I've rebased and reverted the change in behavior, so should be good to merge now.

@@ -528,7 +528,7 @@ end
function set_ssl_cert_locations(cert_loc)
cert_file = isfile(cert_loc) ? cert_loc : Cstring(C_NULL)
cert_dir = isdir(cert_loc) ? cert_loc : Cstring(C_NULL)
cert_file == C_NULL && cert_dir == C_NULL && return
cert_file === C_NULL && cert_dir === C_NULL && return
Copy link
Contributor

@yuyichao yuyichao Jan 31, 2017

Choose a reason for hiding this comment

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

This is still wrong. The function also looks very strange. Is it actually setting the envs to "Cstring(0x0000000000000000)"?

julia> ENV["AAA"] = Cstring(C_NULL)
Cstring(0x0000000000000000)

julia> ENV["AAA"]
"Cstring(0x0000000000000000)"

The setting of the ENV should probably just be folded with the isdir/isfile check (can they possibly both pass?) and clear the corresponding variable if necessary.

@nalimilan nalimilan closed this Feb 15, 2019
@nalimilan nalimilan deleted the nl/is branch February 15, 2019 13:31
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

Successfully merging this pull request may close these issues.

4 participants