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

add at-dot, at-view, and at-views macros; improve at-compat for .= & .+= #316

Merged
merged 5 commits into from
Feb 7, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
work around julia#20247 bug in Julia 0.5
stevengj committed Feb 5, 2017

Verified

This commit was signed with the committer’s verified signature. The key has expired.
lilnasy Arsh
commit 643984cca0cef21ecb1663e4ba61a021cb857e7b
5 changes: 2 additions & 3 deletions src/arraymacros.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Julia 0.6 macros to aid in vectorization: @view, @views, @__dot__ (@.),
# backported from Julia 0.6.

if isdefined(Base, :replace_ref_end!)
import Base.replace_ref_end!
else
# prior to julia#20247, the replace_ref_end! macro had hygiene bugs
if VERSION < v"0.6.0-dev.2406"
function trailingsize(A, n)
s = 1
for i=n:ndims(A)
20 changes: 12 additions & 8 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1638,15 +1638,19 @@ let X = reshape(1:24,2,3,4), Y = 4:-1:1
@test reshape(X[u...,2:end],2,3) == @view X[u...,2:end]
@test reshape(X[(1,)...,(2,)...,2:end],3) == @view X[(1,)...,(2,)...,2:end]

# test macro hygiene
let size=(x,y)-> error("should not happen"), Base=nothing
@test X[1:end,2,2] == @view X[1:end,2,2]
end
# the following tests fail on 0.5 because of bugs in the 0.5 Base.@view
# macro (a bugfix is scheduled to be backported from 0.6)
if VERSION < v"0.5"
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be more specific, otherwise it'll fail on later prereleases and rc's

# test macro hygiene
let size=(x,y)-> error("should not happen"), Base=nothing
@test X[1:end,2,2] == @view X[1:end,2,2]
end

# test that side effects occur only once
let foo = typeof(X)[X]
@test X[2:end-1] == @view (push!(foo,X)[1])[2:end-1]
@test foo == typeof(X)[X, X]
# test that side effects occur only once
let foo = typeof(X)[X]
@test X[2:end-1] == @view (push!(foo,X)[1])[2:end-1]
@test foo == typeof(X)[X, X]
end
end

# test @views macro