-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
fix map! undefined value exposure #56673
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
Merged
LilithHafner
merged 8 commits into
JuliaLang:master
from
adienes:targeted_inplace_map_idxs
Apr 19, 2025
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7717106
fix map! undefined value exposure
adienes e6acfa9
Merge branch 'master' of https://github.com/JuliaLang/julia into targ…
adienes 592d233
apply code review
adienes 980ed0b
Merge branch 'master' into targeted_inplace_map_idxs
adienes b90d3e0
Merge branch 'master' into targeted_inplace_map_idxs
adienes c623093
update for offsetarrays
adienes 4ddaf5d
Merge branch 'master' into targeted_inplace_map_idxs
adienes f9d5fa7
apply code review
adienes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -910,6 +910,9 @@ include("generic_map_tests.jl") | |
generic_map_tests(map, map!) | ||
@test_throws ArgumentError map!(-, [1]) | ||
|
||
# Issue #30624 | ||
@test map!(+, [0,0,0], [1,2], [10,20,30], [100]) == [111,0,0] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you also add a test for #36235 (comment), please? |
||
|
||
test_UInt_indexing(TestAbstractArray) | ||
test_13315(TestAbstractArray) | ||
test_checksquare() | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
eachindex
is here@propagate_inbounds
tomap!
to make it take effect.mapreduce(LinearIndices, intersect, As)
is more elegant thanintersect(map(LinearIndices, As)...)
, unless there is some performance reason to use the latter.inds
is a better name thaninds1
Uh oh!
There was an error while loading. Please reload this page.
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.
thank you for the comments!
the
eachindex
I added for the following reasonso I figured that if we can hit fast-path intersection for ranges rather than collecting the indices we should. Another solution might be to add a fast
intersect(::LinearIndices, ::LinearIndices)
?the
mapreduce
formulation indeed looks nicer to me as well.inds
is a better name thaninds1
Agreed! but I suppose we should decide if in the first place
@inbounds
should allow skipping the check and iterate through the indices of the first argument? I think this is a decision on semantics rather than implementation that I am not empowered to make. the docs should probably be updated if this is intendedThere 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.
Good reason.
@inbounds
should never expose documented semantics that are otherwise not present. This is because you can't count on bounds checks being removed. For exmaple, Julia could be run with-check-bound=yes
or the boundschecking might not be inlined into the callsite where@inbounds
is present. In either case, the bounds checks will remain. Consequently I think the answer to that question is no:@inbounds
should not change the semantics other than to skip bounds checks.