Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Setfield"
uuid = "efcf1570-3423-57d1-acb7-fd33fddbac46"
version = "0.8.2"
version = "0.8.3"

[deps]
ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
Expand Down
7 changes: 4 additions & 3 deletions src/sugar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,21 @@ const HAS_BEGIN_INDEXING = VERSION ≥ v"1.5.0-DEV.666"

function need_dynamic_lens(ex)
return foldtree(false, ex) do yes, x
(yes || x === :end || (HAS_BEGIN_INDEXING && x === :begin) || x === :_)
(yes || x === :end || (HAS_BEGIN_INDEXING && x === :begin) ||
x == Expr(:end) || (HAS_BEGIN_INDEXING && x == Expr(:begin)) || x === :_)
end
end

function lower_index(collection::Symbol, index, dim)
if isexpr(index, :call)
return Expr(:call, lower_index.(collection, index.args, dim)...)
elseif (index === :end)
elseif (index === :end || index == Expr(:end))
if dim === nothing
return :($(Base.lastindex)($collection))
else
return :($(Base.lastindex)($collection, $dim))
end
elseif HAS_BEGIN_INDEXING && (index === :begin)
elseif HAS_BEGIN_INDEXING && (index === :begin || index == Expr(:begin))
if dim === nothing
return :($(Base.firstindex)($collection))
else
Expand Down
Loading