Skip to content

Commit 0d99a99

Browse files
authored
Merge pull request #183 from mlechu/fix-end-parsing-0.8.2
Allow for proposed new parsing of array[end] in Setfield (v0.8)
2 parents 25f5f5a + 57ad277 commit 0d99a99

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Setfield"
22
uuid = "efcf1570-3423-57d1-acb7-fd33fddbac46"
3-
version = "0.8.2"
3+
version = "0.8.3"
44

55
[deps]
66
ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9"

src/sugar.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,21 @@ const HAS_BEGIN_INDEXING = VERSION ≥ v"1.5.0-DEV.666"
6565

6666
function need_dynamic_lens(ex)
6767
return foldtree(false, ex) do yes, x
68-
(yes || x === :end || (HAS_BEGIN_INDEXING && x === :begin) || x === :_)
68+
(yes || x === :end || (HAS_BEGIN_INDEXING && x === :begin) ||
69+
x == Expr(:end) || (HAS_BEGIN_INDEXING && x == Expr(:begin)) || x === :_)
6970
end
7071
end
7172

7273
function lower_index(collection::Symbol, index, dim)
7374
if isexpr(index, :call)
7475
return Expr(:call, lower_index.(collection, index.args, dim)...)
75-
elseif (index === :end)
76+
elseif (index === :end || index == Expr(:end))
7677
if dim === nothing
7778
return :($(Base.lastindex)($collection))
7879
else
7980
return :($(Base.lastindex)($collection, $dim))
8081
end
81-
elseif HAS_BEGIN_INDEXING && (index === :begin)
82+
elseif HAS_BEGIN_INDEXING && (index === :begin || index == Expr(:begin))
8283
if dim === nothing
8384
return :($(Base.firstindex)($collection))
8485
else

0 commit comments

Comments
 (0)