diff --git a/Project.toml b/Project.toml index f622669..6dd38fd 100644 --- a/Project.toml +++ b/Project.toml @@ -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" diff --git a/src/sugar.jl b/src/sugar.jl index 07bdd50..d2a39ad 100644 --- a/src/sugar.jl +++ b/src/sugar.jl @@ -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