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

minor code quality improvements #446

Merged
merged 2 commits into from
Dec 19, 2020

Conversation

aviatesk
Copy link
Member

eliminates some inferrability issues, and also removes some real errors around GlobalRef

src/construct.jl Outdated Show resolved Hide resolved
Copy link
Member

@timholy timholy left a comment

Choose a reason for hiding this comment

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

Great stuff!

src/interpret.jl Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Dec 15, 2020

Codecov Report

Merging #446 (bfd112c) into master (7fa7e2a) will decrease coverage by 0.05%.
The diff coverage is 76.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #446      +/-   ##
==========================================
- Coverage   89.75%   89.69%   -0.06%     
==========================================
  Files          12       12              
  Lines        2322     2330       +8     
==========================================
+ Hits         2084     2090       +6     
- Misses        238      240       +2     
Impacted Files Coverage Δ
src/interpret.jl 88.22% <0.00%> (ø)
src/utils.jl 88.86% <75.00%> (-0.35%) ⬇️
src/breakpoints.jl 95.08% <100.00%> (+0.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7fa7e2a...bdc133c. Read the comment docs.

@aviatesk
Copy link
Member Author

CI failures on nightlies are not related to this PR; #449 will fix them anyway.

_getfile(ln::LineTypes) = ln.file::Symbol
_getfile(ln::Expr) = ln.args[2]::Symbol # assuming ln.head === :line
return CodeTracking.maybe_fixup_stdlib_path(String(_getfile(ln)))
end
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 for pushing such minor optimizations, these changes just circumvents inference limitations around JuliaLang/julia#37342.

Copy link
Member

Choose a reason for hiding this comment

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

Getting rid of invalidation risk is very worthwhile, no apologies needed!

My only concern is again the loss of validation that this is really an Expr of the expected type.

src/utils.jl Outdated
@@ -295,7 +295,8 @@ function lineoffset(framecode::FrameCode)
return offset
end

getline(ln) = Int(isexpr(ln, :line) ? ln.args[1] : ln.line)::Int
getline(ln::LineTypes) = ln.line::Int
getline(ln::Expr) = ln.args[1]::Int # assuming ln.head === :line
Copy link
Member

Choose a reason for hiding this comment

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

The original tries to convert to an Int and then asserts it succeeds; this change requires that they start out as Int. It also doesn't check that ln is a :line Expr/ Are you sure these changes are safe?

Copy link
Member Author

Choose a reason for hiding this comment

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

I found the :line field of LineInfoNode and LineInfoNode are Int, but I didn't track how :line expression is constructed...
I think making explicit conversion here is way more robust and doesn't hurt anything, so let me do that again.


As for the validation for :line expression, I excluded that because I believe we're actually only calling this function on :line expressions, and non-:line Exprs will throw anyway (since it never has .line field). We can do something like getline(ln::Expr) = isexpr(ln, :line) ? ln.args[1] : throw("expected :line expression"), but I feel it's too much ?

_getfile(ln::LineTypes) = ln.file::Symbol
_getfile(ln::Expr) = ln.args[2]::Symbol # assuming ln.head === :line
return CodeTracking.maybe_fixup_stdlib_path(String(_getfile(ln)))
end
Copy link
Member

Choose a reason for hiding this comment

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

Getting rid of invalidation risk is very worthwhile, no apologies needed!

My only concern is again the loss of validation that this is really an Expr of the expected type.

@timholy timholy merged commit 381ee91 into JuliaDebug:master Dec 19, 2020
@timholy
Copy link
Member

timholy commented Dec 19, 2020

Thanks!

@aviatesk aviatesk deleted the minorimprovements branch December 19, 2020 13:52
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.

3 participants