Skip to content

Commit 61bd788

Browse files
committed
Merge pull request #14754 from JuliaLang/ob/arraylen-inlining
arraylen is not affect-free
2 parents 8e036b4 + fcdac63 commit 61bd788

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

base/inference.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2223,7 +2223,7 @@ function effect_free(e::ANY, sv, allow_volatile::Bool)
22232223
if e.head === :call
22242224
if is_known_call_p(e, is_pure_builtin, sv)
22252225
if !allow_volatile
2226-
if is_known_call(e, arrayref, sv)
2226+
if is_known_call(e, arrayref, sv) || is_known_call(e, arraylen, sv)
22272227
return false
22282228
elseif is_known_call(e, getfield, sv)
22292229
# arguments must be immutable to ensure e is affect_free

test/core.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3651,3 +3651,7 @@ end
36513651
# issue #14691
36523652
type T14691; a::UInt; end
36533653
@test (T14691(0).a = 0) === 0
3654+
3655+
# issue #14245
3656+
f14245() = (v = []; push!(v, length(v)); v)
3657+
@test f14245()[1] == 0

0 commit comments

Comments
 (0)