From 02f746db2964d480b1bb0023a5ad290283938871 Mon Sep 17 00:00:00 2001 From: Em Chu Date: Tue, 18 Feb 2025 12:23:12 -0800 Subject: [PATCH] Allow for proposed new parsing of `array[end]` in Setfield --- src/sugar.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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